Skip to content

Commit

Permalink
Add diagnostics/invalid-call-chain tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierSegoviaCordoba committed Apr 16, 2024
1 parent fb7cd59 commit d1245f9
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
FILE: simple-deep-invalid-call-chain-deep-update-each.kt
package com.javiersc.kotlin.kopy.playground

public final fun diagnostics(): R|kotlin/Unit| {
lval qux0: R|com/javiersc/kotlin/kopy/playground/Qux| = R|com/javiersc/kotlin/kopy/playground/Qux.Qux|(R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(7), Int(9))))
lval baz0: R|com/javiersc/kotlin/kopy/playground/Baz| = R|com/javiersc/kotlin/kopy/playground/Baz.Baz|(R|<local>/qux0|, String(Random))
lval bar0: R|com/javiersc/kotlin/kopy/playground/Bar| = R|com/javiersc/kotlin/kopy/playground/Bar.Bar|(R|<local>/baz0|, Boolean(true))
lval foo0: R|com/javiersc/kotlin/kopy/playground/Foo| = R|com/javiersc/kotlin/kopy/playground/Foo.Foo|(R|<local>/bar0|, Char(W))
lval foo10: R|com/javiersc/kotlin/kopy/playground/Foo| = R|<local>/foo0|.R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.invoke: R|com/javiersc/kotlin/kopy/playground/Foo|>|(<L> = foo0@fun R|com/javiersc/kotlin/kopy/playground/Foo|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
(this@R|special/anonymous|, R|<local>/bar0|.R|com/javiersc/kotlin/kopy/playground/Bar.baz|.R|com/javiersc/kotlin/kopy/playground/Baz.qux|.R|com/javiersc/kotlin/kopy/playground/Qux.numbers|).R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.updateEach: R|kotlin/Unit|>|<R|kotlin/Int|>(<L> = updateEach@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <inline=NoInline> {
^ R|<local>/it|.R|kotlin/Int.plus|(Int(42))
}
)
}
)
lval foo11: R|com/javiersc/kotlin/kopy/playground/Foo| = R|<local>/foo0|.R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.copy: R|com/javiersc/kotlin/kopy/playground/Foo|>|(copy@fun R|com/javiersc/kotlin/kopy/playground/Foo|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
(this@R|special/anonymous|, R|<local>/bar0|.R|com/javiersc/kotlin/kopy/playground/Bar.baz|.R|com/javiersc/kotlin/kopy/playground/Baz.qux|.R|com/javiersc/kotlin/kopy/playground/Qux.numbers|).R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.updateEach: R|kotlin/Unit|>|<R|kotlin/Int|>(<L> = updateEach@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <inline=NoInline> {
^ R|<local>/it|.R|kotlin/Int.plus|(Int(42))
}
)
}
)
lval foo20: R|com/javiersc/kotlin/kopy/playground/Foo| = R|<local>/foo0|.R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.invoke: R|com/javiersc/kotlin/kopy/playground/Foo|>|(<L> = foo0@fun R|com/javiersc/kotlin/kopy/playground/Foo|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
(this@R|special/anonymous|, this@R|special/anonymous|.R|com/javiersc/kotlin/kopy/playground/Foo.bar|.R|com/javiersc/kotlin/kopy/playground/Bar.baz|.R|kotlin/apply|<R|com/javiersc/kotlin/kopy/playground/Baz|>(<L> = apply@fun R|com/javiersc/kotlin/kopy/playground/Baz|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
^@apply Unit
}
).R|com/javiersc/kotlin/kopy/playground/Baz.qux|.R|com/javiersc/kotlin/kopy/playground/Qux.numbers|).R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.updateEach: R|kotlin/Unit|>|<R|kotlin/Int|>(<L> = updateEach@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <inline=NoInline> {
^ R|<local>/it|.R|kotlin/Int.plus|(Int(42))
}
)
}
)
lval foo21: R|com/javiersc/kotlin/kopy/playground/Foo| = R|<local>/foo0|.R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.copy: R|com/javiersc/kotlin/kopy/playground/Foo|>|(copy@fun R|com/javiersc/kotlin/kopy/playground/Foo|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
(this@R|special/anonymous|, this@R|special/anonymous|.R|com/javiersc/kotlin/kopy/playground/Foo.bar|.R|com/javiersc/kotlin/kopy/playground/Bar.baz|.R|kotlin/apply|<R|com/javiersc/kotlin/kopy/playground/Baz|>(<L> = apply@fun R|com/javiersc/kotlin/kopy/playground/Baz|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
^@apply Unit
}
).R|com/javiersc/kotlin/kopy/playground/Baz.qux|.R|com/javiersc/kotlin/kopy/playground/Qux.numbers|).R|SubstitutionOverride<com/javiersc/kotlin/kopy/playground/Foo.updateEach: R|kotlin/Unit|>|<R|kotlin/Int|>(<L> = updateEach@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <inline=NoInline> {
^ R|<local>/it|.R|kotlin/Int.plus|(Int(42))
}
)
}
)
}
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Qux : R|kotlin/Any|, R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Qux>| {
public constructor(numbers: R|kotlin/collections/List<kotlin/Int>|): R|com/javiersc/kotlin/kopy/playground/Qux| {
super<R|kotlin/Any|>()
}

public final val numbers: R|kotlin/collections/List<kotlin/Int>| = R|<local>/numbers|
public get(): R|kotlin/collections/List<kotlin/Int>|

public final operator fun component1(): R|kotlin/collections/List<kotlin/Int>|

public final fun copy(numbers: R|kotlin/collections/List<kotlin/Int>| = this@R|com/javiersc/kotlin/kopy/playground/Qux|.R|com/javiersc/kotlin/kopy/playground/Qux.numbers|): R|com/javiersc/kotlin/kopy/playground/Qux|

public open override fun _initKopyable(): R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Qux>| {
}

public open override val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Qux>|
public get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Qux>|

}
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Baz : R|kotlin/Any|, R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Baz>| {
public constructor(qux: R|com/javiersc/kotlin/kopy/playground/Qux|, text: R|kotlin/String|): R|com/javiersc/kotlin/kopy/playground/Baz| {
super<R|kotlin/Any|>()
}

public final val qux: R|com/javiersc/kotlin/kopy/playground/Qux| = R|<local>/qux|
public get(): R|com/javiersc/kotlin/kopy/playground/Qux|

public final val text: R|kotlin/String| = R|<local>/text|
public get(): R|kotlin/String|

public final operator fun component1(): R|com/javiersc/kotlin/kopy/playground/Qux|

public final operator fun component2(): R|kotlin/String|

public final fun copy(qux: R|com/javiersc/kotlin/kopy/playground/Qux| = this@R|com/javiersc/kotlin/kopy/playground/Baz|.R|com/javiersc/kotlin/kopy/playground/Baz.qux|, text: R|kotlin/String| = this@R|com/javiersc/kotlin/kopy/playground/Baz|.R|com/javiersc/kotlin/kopy/playground/Baz.text|): R|com/javiersc/kotlin/kopy/playground/Baz|

public open override fun _initKopyable(): R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Baz>| {
}

public open override val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Baz>|
public get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Baz>|

}
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Bar : R|kotlin/Any|, R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Bar>| {
public constructor(baz: R|com/javiersc/kotlin/kopy/playground/Baz|, isValid: R|kotlin/Boolean|): R|com/javiersc/kotlin/kopy/playground/Bar| {
super<R|kotlin/Any|>()
}

public final val baz: R|com/javiersc/kotlin/kopy/playground/Baz| = R|<local>/baz|
public get(): R|com/javiersc/kotlin/kopy/playground/Baz|

public final val isValid: R|kotlin/Boolean| = R|<local>/isValid|
public get(): R|kotlin/Boolean|

public final operator fun component1(): R|com/javiersc/kotlin/kopy/playground/Baz|

public final operator fun component2(): R|kotlin/Boolean|

public final fun copy(baz: R|com/javiersc/kotlin/kopy/playground/Baz| = this@R|com/javiersc/kotlin/kopy/playground/Bar|.R|com/javiersc/kotlin/kopy/playground/Bar.baz|, isValid: R|kotlin/Boolean| = this@R|com/javiersc/kotlin/kopy/playground/Bar|.R|com/javiersc/kotlin/kopy/playground/Bar.isValid|): R|com/javiersc/kotlin/kopy/playground/Bar|

public open override fun _initKopyable(): R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Bar>| {
}

public open override val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Bar>|
public get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Bar>|

}
@R|com/javiersc/kotlin/kopy/Kopy|() public final data class Foo : R|kotlin/Any|, R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Foo>| {
public constructor(bar: R|com/javiersc/kotlin/kopy/playground/Bar|, letter: R|kotlin/Char|): R|com/javiersc/kotlin/kopy/playground/Foo| {
super<R|kotlin/Any|>()
}

public final val bar: R|com/javiersc/kotlin/kopy/playground/Bar| = R|<local>/bar|
public get(): R|com/javiersc/kotlin/kopy/playground/Bar|

public final val letter: R|kotlin/Char| = R|<local>/letter|
public get(): R|kotlin/Char|

public final operator fun component1(): R|com/javiersc/kotlin/kopy/playground/Bar|

public final operator fun component2(): R|kotlin/Char|

public final fun copy(bar: R|com/javiersc/kotlin/kopy/playground/Bar| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.bar|, letter: R|kotlin/Char| = this@R|com/javiersc/kotlin/kopy/playground/Foo|.R|com/javiersc/kotlin/kopy/playground/Foo.letter|): R|com/javiersc/kotlin/kopy/playground/Foo|

public open override fun _initKopyable(): R|com/javiersc/kotlin/kopy/runtime/Kopyable<com/javiersc/kotlin/kopy/playground/Foo>| {
}

public open override val _atomic: R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>|
public get(): R|kotlinx/atomicfu/AtomicRef<com/javiersc/kotlin/kopy/playground/Foo>|

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// !LANGUAGE: +ContextReceivers
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -MISSING_DEPENDENCY_CLASS -MISSING_DEPENDENCY_SUPERCLASS

package com.javiersc.kotlin.kopy.playground

import com.javiersc.kotlin.kopy.Kopy

fun diagnostics() {
val qux0 = Qux(numbers = listOf(7, 9))
val baz0 = Baz(qux = qux0, text = "Random")
val bar0 = Bar(baz = baz0, isValid = true)
val foo0 = Foo(bar = bar0, letter = 'W')

val foo10 = foo0 { <!INVALID_CALL_CHAIN!>bar0<!>.baz.qux.numbers.updateEach { it + 42 } }
val foo11 = foo0 copy { <!INVALID_CALL_CHAIN!>bar0<!>.baz.qux.numbers.updateEach { it + 42 } }

val foo20 = foo0 { bar.baz.<!INVALID_CALL_CHAIN!>apply<!> {}.qux.numbers.updateEach { it + 42 } }
val foo21 = foo0 copy { bar.baz.<!INVALID_CALL_CHAIN!>apply<!> {}.qux.numbers.updateEach { it + 42 } }
}

@Kopy data class Qux(val numbers: List<Int>)
@Kopy data class Baz(val qux: Qux, val text: String)
@Kopy data class Bar(val baz: Baz, val isValid: Boolean)
@Kopy data class Foo(val bar: Bar, val letter: Char)
Loading

0 comments on commit d1245f9

Please sign in to comment.