KT-11410: Class hierarchy for parts/facade of multi-file class.
Preserve static initialization semantics for parts by introducing a special "clinit trigger" class.
Insert "static initialization trigger" call to every method of a part class, remove this call on inline.
Always mangle names for private functions in multifile class parts to avoid resolution clashes on inheritance.
NB in codegen tests initializers for all non-const vals are wrapped in 'run { ... }',
so that the initializer is not a constant expression, and some static initialization code should be generated.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// WITH_RUNTIME
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.INHERIT_MULTIFILE_PARTS
|
||||
// FILE: Baz.java
|
||||
|
||||
public class Baz {
|
||||
public static String baz() {
|
||||
return Util.foo() + Util.bar();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: bar.kt
|
||||
|
||||
@file:JvmName("Util")
|
||||
@file:JvmMultifileClass
|
||||
public fun bar(): String = barx()
|
||||
|
||||
public fun foox(): String = "O"
|
||||
|
||||
// FILE: foo.kt
|
||||
|
||||
@file:JvmName("Util")
|
||||
@file:JvmMultifileClass
|
||||
public fun foo(): String = foox()
|
||||
|
||||
public fun barx(): String = "K"
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun box(): String = Baz.baz()
|
||||
Reference in New Issue
Block a user