Implementation of super methods calling (#203)

* implemented super call

* tests

* removed redundant code
This commit is contained in:
Igor Chevdar
2017-01-27 16:38:48 +05:00
committed by GitHub
parent 36c90ac47d
commit 01cb9d4cac
6 changed files with 98 additions and 7 deletions
+15
View File
@@ -292,6 +292,21 @@ task empty_substring(type: RunKonanTest) {
source = "runtime/basic/empty_substring.kt"
}
task superFunCall(type: RunKonanTest) {
goldValue = "<fun:C><fun:C1>\n<fun:C><fun:C3>\n"
source = "codegen/basics/superFunCall.kt"
}
task superGetterCall(type: RunKonanTest) {
goldValue = "<prop:C><prop:C1>\n<prop:C><prop:C3>\n"
source = "codegen/basics/superGetterCall.kt"
}
task superSetterCall(type: RunKonanTest) {
goldValue = "<prop:C1><prop:C>zzz\n<prop:C3><prop:C>zzz\n"
source = "codegen/basics/superSetterCall.kt"
}
task enum0(type: RunKonanTest) {
goldValue = "VALUE\n"
source = "codegen/enum/test0.kt"
@@ -0,0 +1,19 @@
open class C {
open fun f() = "<fun:C>"
}
class C1: C() {
override fun f() = super<C>.f() + "<fun:C1>"
}
open class C2: C() {
}
class C3: C2() {
override fun f() = super<C2>.f() + "<fun:C3>"
}
fun main(args: Array<String>) {
println(C1().f())
println(C3().f())
}
@@ -0,0 +1,19 @@
open class C {
open val p1 = "<prop:C>"
}
class C1: C() {
override val p1 = super<C>.p1 + "<prop:C1>"
}
open class C2: C() {
}
class C3: C2() {
override val p1 = super<C2>.p1 + "<prop:C3>"
}
fun main(args: Array<String>) {
println(C1().p1)
println(C3().p1)
}
@@ -0,0 +1,32 @@
open class C {
open var p2 = "<prop:C>"
set(value) { field = "<prop:C>" + value }
}
class C1: C() {
override var p2 = super<C>.p2 + "<prop:C1>"
set(value) {
super<C>.p2 = value
field = "<prop:C1>" + super<C>.p2
}
}
open class C2: C() {
}
class C3: C2() {
override var p2 = super<C2>.p2 + "<prop:C3>"
set(value) {
super<C2>.p2 = value
field = "<prop:C3>" + super<C2>.p2
}
}
fun main(args: Array<String>) {
val c1 = C1()
val c3 = C3()
c1.p2 = "zzz"
c3.p2 = "zzz"
println(c1.p2)
println(c3.p2)
}