Files
kotlin-fork/compiler/testData/codegen/box/initializers/initializers0.kt
T
2024-02-26 13:38:49 +00:00

71 lines
1.3 KiB
Kotlin
Vendored

/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
// JVM_ABI_K1_K2_DIFF: KT-63864
// WITH_STDLIB
import kotlin.test.*
val sb = StringBuilder()
class A {
init{
sb.appendLine ("A::init")
}
val a = 1
companion object :B(1) {
init {
sb.appendLine ("A::companion")
}
fun foo() {
sb.appendLine("A::companion::foo")
}
}
object AObj : B(){
init {
sb.appendLine("A::Obj")
}
fun foo() {
sb.appendLine("A::AObj::foo")
}
}
}
fun box(): String {
sb.appendLine("main")
A.foo()
A.foo()
A.AObj.foo()
A.AObj.foo()
assertEquals("""
main
B::constructor(1)
A::companion
A::companion::foo
A::companion::foo
B::constructor(0)
B::constructor()
A::Obj
A::AObj::foo
A::AObj::foo
""".trimIndent(), sb.toString())
return "OK"
}
open class B(val a:Int, val b:Int) {
constructor(a:Int):this (a, 0) {
sb.appendLine("B::constructor(" + a.toString()+ ")")
}
constructor():this(0) {
sb.appendLine("B::constructor()")
}
}