JVM, JVM IR: erase generic SAM supertypes

Also, do not try to use invokedynamic on SAM calls with intersection
types, because intersection type is not allowed as an immediate type
projection of a supertype, and constructing a fake override in
LambdaMetafactoryArgumentsBuilder led to an exception. This fixes the
problem which was worked around earlier in e6c089ef, effectively
reverting that commit.

The main motivation for this change is that LambdaMetafactory also
doesn't generate generic signature for SAM wrapper classes at runtime.
Since these classes are synthetic, nobody should rely on the fact that
they have generic supertypes, which was observable only via Java
reflection.

 #KT-46149 Fixed
 #KT-46238 Fixed
This commit is contained in:
Alexander Udalov
2021-04-21 18:41:18 +02:00
parent 1093bffc62
commit b2005302dc
30 changed files with 97 additions and 45 deletions
@@ -1,5 +1,5 @@
@kotlin.Metadata
final class<<T:Ljava/lang/Object;>Ljava/lang/Object;LSam<TT;>;> TKt$genericSam$1 {
final class<<T:Ljava/lang/Object;>Ljava/lang/Object;LSam;> TKt$genericSam$1 {
// source: 't.kt'
public final <()TT;> method get(): java.lang.Object
<null> method <init>(p0: kotlin.jvm.functions.Function0): void
@@ -9,7 +9,7 @@ final class<<T:Ljava/lang/Object;>Ljava/lang/Object;LSam<TT;>;> TKt$genericSam$
}
@kotlin.Metadata
final class<<T:Ljava/lang/Object;>Ljava/lang/Object;LSam<TT;>;> TKt$genericSamGet$1 {
final class<<T:Ljava/lang/Object;>Ljava/lang/Object;LSam;> TKt$genericSamGet$1 {
// source: 't.kt'
public final <()TT;> method get(): java.lang.Object
<null> method <init>(p0: kotlin.jvm.functions.Function0): void