Files
kotlin-fork/compiler/testData/codegen/box/compileKotlinAgainstKotlin/copySamOnInline.kt
T
Mads Ager 261482904c [FIR] Give external package fragments different module descriptors.
The inliner uses module descriptors to figure out if it needs to
regenerate objects.

We should avoid the use of descriptors in the inliner, but this
works as a first quick fix.
2021-11-25 13:20:31 +03:00

35 lines
890 B
Kotlin
Vendored

// FULL_JDK
// WITH_STDLIB
// MODULE: lib
// FILE: A.kt
package test
import java.util.concurrent.Callable
class A(val callable: Callable<String>)
inline fun doWork(noinline job: () -> String): Callable<String> {
val a = A(Callable(job))
return a.callable
}
var sameModule = doWork { "O" }
// MODULE: main(lib)
// FILE: B.kt
import test.*
fun box(): String {
val anotherModule = doWork { "K" }
if (sameModule.javaClass.name == anotherModule.javaClass.name) return "class should be regenerated, but ${anotherModule.javaClass.name}"
if (sameModule.javaClass.name.contains("inlined")) return "Sam in same module shouldn't be copied, but ${sameModule.javaClass.name}"
if (!anotherModule.javaClass.name.contains("inlined")) return "Sam in another module should be copied, but ${sameModule.javaClass.name}"
return sameModule.call() + anotherModule.call()
}