Files
kotlin-fork/compiler/testData/codegen/box/topLevelPrivate/noPrivateNoAccessorsInMultiFileFacade2.kt
T
Alexander Udalov 4be0e00071 JVM IR: support multi-file classes
Without the `-Xmultifile-parts-inherit` mode for now.

This is implemented as follows: FileClassLowering collects information
about multifile parts and the corresponding facades, which a later
GenerateMultifileFacades phase uses to generate new IrFile instances and
add it to the module fragment that's being compiled.

Note that GenerateMultifileFacades is in the end of lowering phases
because delegates in the facade should be generated for all additional
functions generated by certain lowerings (default arguments,
JvmOverloads, etc.). If GenerateMultifileFacades was right after
FileClassLowering, they would still be generated, but we'd then process
them in lowerings mentioned above, which would result in duplicated
logic in the bytecode. There's a new bytecode text test which checks
that this doesn't happen for functions with default arguments.
2019-08-05 21:27:21 +02:00

29 lines
678 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_RUNTIME
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("TestKt")
package test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
public var prop = "fail"
private set
private fun test() = "K"
fun box(): String {
val clazz = Class.forName("test.TestKt")
assertEquals(2, clazz.declaredMethods.size, "Facade should have only box method")
val methods = clazz.declaredMethods.map { it.name }
assertTrue(methods.contains("box"), "Facade should have box method")
assertTrue(methods.contains("getProp"), "Facade should have box method")
return {
prop = "O"
prop + test()
}()
}