diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt index a36bfd41d89..1c0e59c8543 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt @@ -286,7 +286,8 @@ abstract class AnnotationCodegen( when { declaration.origin.isSynthetic -> true - declaration.origin == JvmLoweredDeclarationOrigin.INLINE_CLASS_GENERATED_IMPL_METHOD -> + declaration.origin == JvmLoweredDeclarationOrigin.INLINE_CLASS_GENERATED_IMPL_METHOD || + declaration.origin == IrDeclarationOrigin.GENERATED_SAM_IMPLEMENTATION -> true else -> false diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt index d1b175d8369..dd96882e1a7 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt @@ -8,7 +8,7 @@ public interface<Ljava/lang/Object;> Sam { final class TKt$sam$Sam$0 { // source: 't.kt' public final @org.jetbrains.annotations.NotNull <()Lkotlin/Function<*>;> method getFunctionDelegate(): kotlin.Function - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void + method (p0: kotlin.jvm.functions.Function0): void public final method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean public synthetic final method get(): java.lang.Object public final method hashCode(): int diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface_ir.txt deleted file mode 100644 index 112f9631bfd..00000000000 --- a/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface_ir.txt +++ /dev/null @@ -1,16 +0,0 @@ -@kotlin.Metadata -final class TKt$sam$Sam$0 { - // source: 't.kt' - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void - public synthetic final method get(): java.lang.Object - enclosing class TKt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class TKt$sam$Sam$0 -} - -@kotlin.Metadata -public final class TKt { - // source: 't.kt' - public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object - inner (anonymous) class TKt$sam$Sam$0 -} diff --git a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt index 3d169515122..9db99e321b9 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt @@ -1,24 +1,17 @@ -// FILE: test.kt -fun test1() { - val f = { } - val t1 = Runnable(f) - val t2 = Runnable(f) +// WITH_RUNTIME + +class A { + fun test1() { + val f = { } + val t1 = Runnable(f) + val t2 = Runnable(f) + } } -fun test2() { - val t1 = getWrapped1() - val t2 = getWrapped2() +class B { + fun test2() { + val f = { } + val t1 = Runnable(f) + val t2 = Runnable(f) + } } - -// FILE: f1.kt -fun getWrapped1(): Runnable { - val f = { } - return Runnable(f) -} - -// FILE: f2.kt -fun getWrapped2(): Runnable { - val f = { } - return Runnable(f) -} - diff --git a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt index d2db69c4cc3..17ce13004a7 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt @@ -1,9 +1,19 @@ @kotlin.Metadata -final class F1Kt$getWrapped1$f$1 { - // source: 'f1.kt' - enclosing method F1Kt.getWrapped1()Ljava/lang/Runnable; - public final static field INSTANCE: F1Kt$getWrapped1$f$1 - inner (anonymous) class F1Kt$getWrapped1$f$1 +final class A$sam$java_lang_Runnable$0 { + // source: 'reusedSamWrapperClasses.kt' + enclosing class A + private synthetic final field function: kotlin.jvm.functions.Function0 + inner (anonymous) class A$sam$java_lang_Runnable$0 + method (p0: kotlin.jvm.functions.Function0): void + public synthetic final method run(): void +} + +@kotlin.Metadata +final class A$test1$f$1 { + // source: 'reusedSamWrapperClasses.kt' + enclosing method A.test1()V + public final static field INSTANCE: A$test1$f$1 + inner (anonymous) class A$test1$f$1 static method (): void method (): void public synthetic bridge method invoke(): java.lang.Object @@ -11,29 +21,20 @@ final class F1Kt$getWrapped1$f$1 { } @kotlin.Metadata -final class F1Kt$sam$java_lang_Runnable$0 { - // source: 'f1.kt' - enclosing class F1Kt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class F1Kt$sam$java_lang_Runnable$0 - method (p0: kotlin.jvm.functions.Function0): void - public synthetic final method run(): void +public final class A { + // source: 'reusedSamWrapperClasses.kt' + inner (anonymous) class A$sam$java_lang_Runnable$0 + inner (anonymous) class A$test1$f$1 + public method (): void + public final method test1(): void } @kotlin.Metadata -public final class F1Kt { - // source: 'f1.kt' - inner (anonymous) class F1Kt$getWrapped1$f$1 - inner (anonymous) class F1Kt$sam$java_lang_Runnable$0 - public final static @org.jetbrains.annotations.NotNull method getWrapped1(): java.lang.Runnable -} - -@kotlin.Metadata -final class F2Kt$getWrapped2$f$1 { - // source: 'f2.kt' - enclosing method F2Kt.getWrapped2()Ljava/lang/Runnable; - public final static field INSTANCE: F2Kt$getWrapped2$f$1 - inner (anonymous) class F2Kt$getWrapped2$f$1 +final class B$test2$f$1 { + // source: 'reusedSamWrapperClasses.kt' + enclosing method B.test2()V + public final static field INSTANCE: B$test2$f$1 + inner (anonymous) class B$test2$f$1 static method (): void method (): void public synthetic bridge method invoke(): java.lang.Object @@ -41,50 +42,9 @@ final class F2Kt$getWrapped2$f$1 { } @kotlin.Metadata -final class F2Kt$sam$java_lang_Runnable$0 { - // source: 'f2.kt' - enclosing class F2Kt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class F2Kt$sam$java_lang_Runnable$0 - method (p0: kotlin.jvm.functions.Function0): void - public synthetic final method run(): void -} - -@kotlin.Metadata -public final class F2Kt { - // source: 'f2.kt' - inner (anonymous) class F2Kt$getWrapped2$f$1 - inner (anonymous) class F2Kt$sam$java_lang_Runnable$0 - public final static @org.jetbrains.annotations.NotNull method getWrapped2(): java.lang.Runnable -} - -@kotlin.Metadata -final class TestKt$sam$java_lang_Runnable$0 { - // source: 'test.kt' - enclosing class TestKt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class TestKt$sam$java_lang_Runnable$0 - method (p0: kotlin.jvm.functions.Function0): void - public synthetic final method run(): void -} - -@kotlin.Metadata -final class TestKt$test1$f$1 { - // source: 'test.kt' - enclosing method TestKt.test1()V - public final static field INSTANCE: TestKt$test1$f$1 - inner (anonymous) class TestKt$test1$f$1 - static method (): void - method (): void - public synthetic bridge method invoke(): java.lang.Object - public final method invoke(): void -} - -@kotlin.Metadata -public final class TestKt { - // source: 'test.kt' - inner (anonymous) class TestKt$sam$java_lang_Runnable$0 - inner (anonymous) class TestKt$test1$f$1 - public final static method test1(): void - public final static method test2(): void +public final class B { + // source: 'reusedSamWrapperClasses.kt' + inner (anonymous) class B$test2$f$1 + public method (): void + public final method test2(): void } diff --git a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses_ir.txt deleted file mode 100644 index 4aedc6a0a58..00000000000 --- a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses_ir.txt +++ /dev/null @@ -1,90 +0,0 @@ -@kotlin.Metadata -final class F1Kt$getWrapped1$f$1 { - // source: 'f1.kt' - enclosing method F1Kt.getWrapped1()Ljava/lang/Runnable; - public final static field INSTANCE: F1Kt$getWrapped1$f$1 - inner (anonymous) class F1Kt$getWrapped1$f$1 - static method (): void - method (): void - public synthetic bridge method invoke(): java.lang.Object - public final method invoke(): void -} - -@kotlin.Metadata -final class F1Kt$sam$java_lang_Runnable$0 { - // source: 'f1.kt' - enclosing class F1Kt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class F1Kt$sam$java_lang_Runnable$0 - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void - public synthetic final method run(): void -} - -@kotlin.Metadata -public final class F1Kt { - // source: 'f1.kt' - inner (anonymous) class F1Kt$getWrapped1$f$1 - inner (anonymous) class F1Kt$sam$java_lang_Runnable$0 - public final static @org.jetbrains.annotations.NotNull method getWrapped1(): java.lang.Runnable -} - -@kotlin.Metadata -final class F2Kt$getWrapped2$f$1 { - // source: 'f2.kt' - enclosing method F2Kt.getWrapped2()Ljava/lang/Runnable; - public final static field INSTANCE: F2Kt$getWrapped2$f$1 - inner (anonymous) class F2Kt$getWrapped2$f$1 - static method (): void - method (): void - public synthetic bridge method invoke(): java.lang.Object - public final method invoke(): void -} - -@kotlin.Metadata -final class F2Kt$sam$java_lang_Runnable$0 { - // source: 'f2.kt' - enclosing class F2Kt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class F2Kt$sam$java_lang_Runnable$0 - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void - public synthetic final method run(): void -} - -@kotlin.Metadata -public final class F2Kt { - // source: 'f2.kt' - inner (anonymous) class F2Kt$getWrapped2$f$1 - inner (anonymous) class F2Kt$sam$java_lang_Runnable$0 - public final static @org.jetbrains.annotations.NotNull method getWrapped2(): java.lang.Runnable -} - -@kotlin.Metadata -final class TestKt$sam$java_lang_Runnable$0 { - // source: 'test.kt' - enclosing class TestKt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class TestKt$sam$java_lang_Runnable$0 - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void - public synthetic final method run(): void -} - -@kotlin.Metadata -final class TestKt$test1$f$1 { - // source: 'test.kt' - enclosing method TestKt.test1()V - public final static field INSTANCE: TestKt$test1$f$1 - inner (anonymous) class TestKt$test1$f$1 - static method (): void - method (): void - public synthetic bridge method invoke(): java.lang.Object - public final method invoke(): void -} - -@kotlin.Metadata -public final class TestKt { - // source: 'test.kt' - inner (anonymous) class TestKt$sam$java_lang_Runnable$0 - inner (anonymous) class TestKt$test1$f$1 - public final static method test1(): void - public final static method test2(): void -} diff --git a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt index 764c64f3e9c..fd4941ff5d0 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt @@ -1,7 +1,7 @@ @kotlin.Metadata public final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnable$0 { // source: 'samAdapterAndInlinedOne.kt' - public method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void + public method (p0: kotlin.jvm.functions.Function0): void public synthetic final method run(): void enclosing class test/SamAdapterAndInlinedOneKt private synthetic final field function: kotlin.jvm.functions.Function0 @@ -11,7 +11,7 @@ public final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnabl @kotlin.Metadata final class test/SamAdapterAndInlinedOneKt$sam$java_lang_Runnable$0 { // source: 'samAdapterAndInlinedOne.kt' - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void + method (p0: kotlin.jvm.functions.Function0): void public synthetic final method run(): void enclosing class test/SamAdapterAndInlinedOneKt private synthetic final field function: kotlin.jvm.functions.Function0 diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt index dac033830da..ba9f90c64b8 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt @@ -8,7 +8,7 @@ public interface<Ljava/lang/Object;> Sam { final class TKt$sam$Sam$0 { // source: 't.kt' public final @org.jetbrains.annotations.NotNull <()Lkotlin/Function<*>;> method getFunctionDelegate(): kotlin.Function - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void + method (p0: kotlin.jvm.functions.Function0): void public final method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean public synthetic final method get(): java.lang.Object public final method hashCode(): int diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface_ir.txt deleted file mode 100644 index 8376792664a..00000000000 --- a/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface_ir.txt +++ /dev/null @@ -1,16 +0,0 @@ -@kotlin.Metadata -final class TKt$sam$Sam$0 { - // source: 't.kt' - method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void - public synthetic final method get(): java.lang.Object - enclosing class TKt - private synthetic final field function: kotlin.jvm.functions.Function0 - inner (anonymous) class TKt$sam$Sam$0 -} - -@kotlin.Metadata -public final class TKt { - // source: 't.kt' - public final static <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String - inner (anonymous) class TKt$sam$Sam$0 -} diff --git a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt index fc5180b6a8a..a244633ffd7 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt @@ -64,7 +64,7 @@ public final class B$sam$i$java_lang_Runnable$0 { enclosing class B private synthetic final field function: kotlin.jvm.functions.Function0 inner (anonymous) class B$sam$i$java_lang_Runnable$0 - public method (@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void + public method (p0: kotlin.jvm.functions.Function0): void public synthetic final method run(): void }