Support properties in compatibility mode

This commit is contained in:
Mikhael Bogdanov
2018-05-29 14:36:30 +02:00
parent 0498c3b765
commit ad717d5335
7 changed files with 188 additions and 0 deletions
@@ -0,0 +1,43 @@
// !API_VERSION: 1.3
// !JVM_DEFAULT_MODE: compatibility
// FILE: Simple.java
public interface Simple extends KInterface2 {
default String test() {
return KInterface2.DefaultImpls.getBar(this);
}
}
// FILE: Foo.java
public class Foo implements Simple {
}
// FILE: main.kt
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface KInterface<T> {
val foo: T
@JvmDefault
val bar: T
get() = foo
}
interface KInterface2 : KInterface<String> {
@JvmDefault
override val foo: String
get() = "OK"
}
fun box(): String {
val result = Foo().test()
if (result != "OK") return "fail 1: ${result}"
return Foo().bar
}
@@ -0,0 +1,40 @@
// !API_VERSION: 1.3
// !JVM_DEFAULT_MODE: compatibility
// FILE: Simple.java
public interface Simple extends KInterface2 {
default String test() {
return KInterface2.DefaultImpls.getBar(this);
}
}
// FILE: Foo.java
public class Foo implements Simple {
public String getBar() {
return "fail";
}
}
// FILE: main.kt
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface KInterface<T> {
val foo: T
@JvmDefault
val bar: T
get() = foo
}
interface KInterface2 : KInterface<String> {
@JvmDefault
override val foo: String
get() = "OK"
}
fun box(): String {
return Foo().test()
}
@@ -0,0 +1,42 @@
// !API_VERSION: 1.3
// !JVM_DEFAULT_MODE: compatibility
// FILE: Simple.java
public interface Simple extends KInterface3 {
default String test() {
return KInterface3.DefaultImpls.getBar(this);
}
}
// FILE: Foo.java
public class Foo implements Simple {
}
// FILE: main.kt
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface KInterface<T> {
val foo: T
@JvmDefault
val bar: T
get() = foo
}
interface KInterface2 : KInterface<String> {
@JvmDefault
override val foo: String
get() = "OK"
}
interface KInterface3 : KInterface2 {
}
fun box(): String {
return Foo().test()
}
@@ -0,0 +1,26 @@
// !API_VERSION: 1.3
// !JVM_DEFAULT_MODE: compatibility
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface KInterface {
@JvmDefault
var bar: String
get() = "OK"
set(field) {}
}
interface KInterface2 : KInterface {
}
// 1 INVOKESTATIC KInterface2.access\$getBar\$jd
// 1 INVOKESTATIC KInterface2.access\$setBar\$jd
// 1 INVOKESTATIC KInterface.access\$getBar\$jd
// 1 INVOKESTATIC KInterface.access\$setBar\$jd
// 1 INVOKESPECIAL KInterface2.getBar
// 1 INVOKESPECIAL KInterface2.setBar
// 1 INVOKESPECIAL KInterface.getBar
// 1 INVOKESPECIAL KInterface.setBar