Generate synthetic annotation method in interface if -Xjvm-default is on

This commit is contained in:
Mikhael Bogdanov
2021-02-23 14:45:30 +01:00
parent a101d12c78
commit 8764bb09f2
19 changed files with 431 additions and 5 deletions
@@ -0,0 +1,31 @@
// WITH_STDLIB
// JVM_TARGET: 1.8
// MODULE: lib
// !JVM_DEFAULT_MODE: all-compatibility
// FILE: 1.kt
interface Foo<T> {
fun test(p: T) = "fail"
val T.prop: String
get() = "fail"
}
// MODULE: main(lib)
// !JVM_DEFAULT_MODE: all
// FILE: main.kt
interface Foo2: Foo<String> {
override fun test(p: String) : String = p
override val String.prop: String
get() = this
}
interface Foo3: Foo<String>, Foo2
class Base : Foo3
fun box(): String {
val base = Base()
return base.test("O") + with(base) { "K".prop }
}
@@ -0,0 +1,30 @@
// WITH_STDLIB
// JVM_TARGET: 1.8
// MODULE: lib
// !JVM_DEFAULT_MODE: all
// FILE: 1.kt
interface Foo<T> {
fun test(p: T) = "fail"
val T.prop: String
get() = "fail"
}
// MODULE: main(lib)
// !JVM_DEFAULT_MODE: all-compatibility
// FILE: main.kt
interface Foo2: Foo<String> {
override fun test(p: String) : String = p
override val String.prop: String
get() = this
}
interface Foo3: Foo<String>, Foo2
class Base : Foo3
fun box(): String {
val base = Base()
return base.test("O") + with(base) { "K".prop }
}
@@ -0,0 +1,20 @@
// !JVM_DEFAULT_MODE: all
// JVM_TARGET: 1.8
// WITH_RUNTIME
// MODULE: lib
// FILE: 1.kt
interface Test {
val prop: String
get() = "OK"
}
// MODULE: main(lib)
// FILE: 2.kt
interface Test2 : Test {
override val prop: String
get() = super.prop
}
fun box(): String {
return object : Test2 {}.prop
}
@@ -0,0 +1,12 @@
// !JVM_DEFAULT_MODE: all-compatibility
// JVM_TARGET: 1.8
// WITH_RUNTIME
@Target(AnnotationTarget.PROPERTY)
annotation class Foo
interface Deprecated {
@Foo
val prop: String
}
@@ -0,0 +1,21 @@
@kotlin.Metadata
public final class Deprecated$DefaultImpls {
// source: 'interfaceProperty.kt'
public synthetic deprecated static @Foo method getProp$annotations(): void
public final inner class Deprecated$DefaultImpls
}
@kotlin.Metadata
public interface Deprecated {
// source: 'interfaceProperty.kt'
public abstract @org.jetbrains.annotations.NotNull method getProp(): java.lang.String
public final inner class Deprecated$DefaultImpls
}
@kotlin.annotation.Target
@java.lang.annotation.Retention
@java.lang.annotation.Target
@kotlin.Metadata
public annotation class Foo {
// source: 'interfaceProperty.kt'
}
@@ -0,0 +1,11 @@
// !JVM_DEFAULT_MODE: enable
// JVM_TARGET: 1.8
// WITH_RUNTIME
@Target(AnnotationTarget.PROPERTY)
annotation class Foo
interface Deprecated {
@Foo
val prop: String
}
@@ -0,0 +1,21 @@
@kotlin.Metadata
public final class Deprecated$DefaultImpls {
// source: 'interfaceProperty.kt'
public synthetic deprecated static @Foo method getProp$annotations(): void
public final inner class Deprecated$DefaultImpls
}
@kotlin.Metadata
public interface Deprecated {
// source: 'interfaceProperty.kt'
public abstract @org.jetbrains.annotations.NotNull method getProp(): java.lang.String
public final inner class Deprecated$DefaultImpls
}
@kotlin.annotation.Target
@java.lang.annotation.Retention
@java.lang.annotation.Target
@kotlin.Metadata
public annotation class Foo {
// source: 'interfaceProperty.kt'
}
@@ -0,0 +1,11 @@
// !JVM_DEFAULT_MODE: all
// JVM_TARGET: 1.8
// WITH_RUNTIME
@Target(AnnotationTarget.PROPERTY)
annotation class Foo
interface Deprecated {
@Foo
val prop: String
}
@@ -0,0 +1,14 @@
@kotlin.Metadata
public interface Deprecated {
// source: 'interfaceProperty.kt'
public synthetic deprecated static @Foo method getProp$annotations(): void
public abstract @org.jetbrains.annotations.NotNull method getProp(): java.lang.String
}
@kotlin.annotation.Target
@java.lang.annotation.Retention
@java.lang.annotation.Target
@kotlin.Metadata
public annotation class Foo {
// source: 'interfaceProperty.kt'
}