KT 3492: Bug in bytecode generation for labeled super call from inner class & Property generation refactoring

This commit is contained in:
Mikhael Bogdanov
2013-04-09 19:45:14 +04:00
parent 8a14087c91
commit 3da3f94b4e
13 changed files with 230 additions and 115 deletions
@@ -0,0 +1,44 @@
//inspired by kt3492
trait BK {
fun foo(): String
fun bar(): String
}
trait KTrait: BK {
override fun foo() = bar()
}
open abstract class K : KTrait {
}
class A : K() {
override fun foo() = "A.foo"
override fun bar() = "A.bar"
inner class B : K() {
override fun foo() = "B.foo"
override fun bar() = "B.bar"
fun test1() = super<K>@A.foo()
fun test2() = super<K>@B.foo()
fun test3() = super<K>.foo()
fun test4() = super@A.foo()
fun test5() = super@B.foo()
fun test6() = super.foo()
}
}
fun box(): String {
val b = A().B()
if (b.test1() != "A.bar") return "test1 ${b.test1()}"
if (b.test2() != "B.bar") return "test2 ${b.test2()}"
if (b.test3() != "B.bar") return "test3 ${b.test3()}"
if (b.test4() != "A.bar") return "test4 ${b.test4()}"
if (b.test5() != "B.bar") return "test5 ${b.test5()}"
if (b.test6() != "B.bar") return "test6 ${b.test6()}"
return "OK"
}
@@ -0,0 +1,43 @@
//inspired by kt3492
trait Base {
val foo: String
fun bar(): String
}
abstract class KWithOverride : Base {
override val foo = bar()
}
abstract class K : KWithOverride() {
}
class A : K() {
override val foo = "A.foo"
override fun bar() = "A.bar"
inner class B : K() {
override val foo = "B.foo"
override fun bar() = "B.bar"
fun test1() = super<K>@A.foo
fun test2() = super<K>@B.foo
fun test3() = super<K>.foo
fun test4() = super@A.foo
fun test5() = super@B.foo
fun test6() = super.foo
}
}
fun box(): String {
val b = A().B()
if (b.test1() != "A.bar") return "test1 ${b.test1()}"
if (b.test2() != "B.bar") return "test2 ${b.test2()}"
if (b.test3() != "B.bar") return "test3 ${b.test3()}"
if (b.test4() != "A.bar") return "test4 ${b.test4()}"
if (b.test5() != "B.bar") return "test5 ${b.test5()}"
if (b.test6() != "B.bar") return "test6 ${b.test6()}"
return "OK"
}
@@ -0,0 +1,19 @@
open class A {
open fun foo2(): String = "OK"
}
open class B : A() {
}
class C : B() {
inner class D {
val foo: String = super<B>@C.foo2()
}
}
fun box() : String {
val obj = C().D();
return obj.foo
}
@@ -0,0 +1,15 @@
open class A {
open val foo: String = "OK"
}
open class B : A() {
}
class C : B() {
inner class D {
val foo: String = super<B>@C.foo
}
}
fun box() = C().D().foo
@@ -0,0 +1,19 @@
trait ATrait {
open fun foo2(): String = "OK"
}
open class B : ATrait {
}
class C : B() {
inner class D {
val foo: String = super<B>@C.foo2()
}
}
fun box() : String {
val obj = C().D();
return obj.foo
}
@@ -0,0 +1,16 @@
trait A {
open val foo: String
get() = "OK"
}
open class B : A {
}
class C : B() {
inner class D {
val foo: String = super<B>@C.foo
}
}
fun box() = C().D().foo