JVM: fix EnclosingMethod information for SAMs in inline lambdas
Pass parentContext to SamWrapperCodegen from the outside instead of using the one from parentCodegen. The difference is that in case of an inline lambda, we're creating an InlineLambdaContext whose parent is a ClosureContext, but the codegen for that lambda has that latter ClosureContext as its context. So the getNonInlineOuterContext call in SamWrapperCodegen.generateInnerClassInformation wasn't able to identify that this is a context of a lambda that needs to be skipped, and generated it as EnclosingMethod, which caused Java reflection to fail because once that lambda was inlined, it was removed and thus didn't make it to runtime. #KT-44827 Fixed
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
public <null> method getFunctionDelegate(): kotlin.Function
|
||||
public <null> method hashCode(): int
|
||||
enclosing class TKt
|
||||
enclosing method TKt.genericSam()Ljava/lang/Object;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
// source: 't.kt'
|
||||
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
enclosing class TKt
|
||||
enclosing method TKt.genericSam()Ljava/lang/Object;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
public <null> method getFunctionDelegate(): kotlin.Function
|
||||
public <null> method hashCode(): int
|
||||
enclosing class TKt
|
||||
enclosing method TKt.specializedSam()Ljava/lang/String;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
// source: 't.kt'
|
||||
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
enclosing class TKt
|
||||
enclosing method TKt.specializedSam()Ljava/lang/String;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
public <null> method getFunctionDelegate(): kotlin.Function
|
||||
public <null> method hashCode(): int
|
||||
enclosing class TKt
|
||||
enclosing method TKt.genericSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
// source: 't.kt'
|
||||
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
enclosing class TKt
|
||||
enclosing method TKt.genericSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
@kotlin.Metadata
|
||||
synthetic final class<null> TKt$sam$Sam$0 {
|
||||
// source: 't.kt'
|
||||
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
enclosing class TKt
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class<null> TKt {
|
||||
// source: 't.kt'
|
||||
public final static <<T:Ljava/lang/Object;>(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
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@kotlin.Metadata
|
||||
synthetic final class A$sam$java_lang_Runnable$0 {
|
||||
// source: 'reusedSamWrapperClasses.kt'
|
||||
enclosing class A
|
||||
enclosing method A.test1()V
|
||||
private synthetic final field function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class A$sam$java_lang_Runnable$0
|
||||
method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
@kotlin.Metadata
|
||||
synthetic 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 <init>(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 <clinit>(): void
|
||||
method <init>(): void
|
||||
public synthetic bridge method invoke(): java.lang.Object
|
||||
public final method invoke(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
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 <init>(): void
|
||||
public final method test1(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
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 <clinit>(): void
|
||||
method <init>(): void
|
||||
public synthetic bridge method invoke(): java.lang.Object
|
||||
public final method invoke(): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class B {
|
||||
// source: 'reusedSamWrapperClasses.kt'
|
||||
inner (anonymous) class B$test2$f$1
|
||||
public method <init>(): void
|
||||
public final method test2(): void
|
||||
}
|
||||
@@ -3,7 +3,7 @@ public synthetic final class<null> test/SamAdapterAndInlinedOneKt$sam$i$java_la
|
||||
// source: 'samAdapterAndInlinedOne.kt'
|
||||
public <null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method run(): void
|
||||
enclosing class test/SamAdapterAndInlinedOneKt
|
||||
enclosing method test/SamAdapterAndInlinedOneKt.makeRunnable(Lkotlin/jvm/functions/Function0;)Ljava/lang/Runnable;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnable$0
|
||||
}
|
||||
@@ -13,7 +13,7 @@ synthetic final class<null> test/SamAdapterAndInlinedOneKt$sam$java_lang_Runnab
|
||||
// source: 'samAdapterAndInlinedOne.kt'
|
||||
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method run(): void
|
||||
enclosing class test/SamAdapterAndInlinedOneKt
|
||||
enclosing method test/SamAdapterAndInlinedOneKt.noInline(Lkotlin/jvm/functions/Function0;)Ljava/lang/Runnable;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class test/SamAdapterAndInlinedOneKt$sam$java_lang_Runnable$0
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
public <null> method getFunctionDelegate(): kotlin.Function
|
||||
public <null> method hashCode(): int
|
||||
enclosing class TKt
|
||||
enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ synthetic final class<null> TKt$sam$Sam$0 {
|
||||
// source: 't.kt'
|
||||
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
enclosing class TKt
|
||||
enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
@kotlin.Metadata
|
||||
synthetic final class<null> TKt$sam$Sam$0 {
|
||||
// source: 't.kt'
|
||||
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
public synthetic final <null> method get(): java.lang.Object
|
||||
enclosing class TKt
|
||||
private synthetic final field <null> function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class<null> TKt {
|
||||
// source: 't.kt'
|
||||
public final static <(Lkotlin/jvm/functions/Function0<Ljava/lang/String;>;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String
|
||||
inner (anonymous) class TKt$sam$Sam$0
|
||||
}
|
||||
+1
-1
@@ -61,7 +61,7 @@ public final class B$runnable2$1 {
|
||||
@kotlin.Metadata
|
||||
public synthetic final class B$sam$i$java_lang_Runnable$0 {
|
||||
// source: 'wrapperInlinedFromAnotherClass.kt'
|
||||
enclosing class B
|
||||
enclosing method B.runnableSamCtor(Lkotlin/jvm/functions/Function0;)Ljava/lang/Runnable;
|
||||
private synthetic final field function: kotlin.jvm.functions.Function0
|
||||
inner (anonymous) class B$sam$i$java_lang_Runnable$0
|
||||
public method <init>(p0: kotlin.jvm.functions.Function0): void
|
||||
|
||||
Reference in New Issue
Block a user