diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 95a931926c1..4ae34240eab 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -12178,6 +12178,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("subtypeOfFunctionalTypeToFunInterfaceConversion.kt") public void testSubtypeOfFunctionalTypeToFunInterfaceConversion() throws Exception { runTest("compiler/testData/codegen/box/funInterface/subtypeOfFunctionalTypeToFunInterfaceConversion.kt"); @@ -15922,6 +15927,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt"); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index 9ca3ff6074c..88f30ab34a9 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -159,8 +159,8 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) private val adaptedReferenceOriginalTarget: IrFunction? = adapteeCall?.symbol?.owner private val isAdaptedReference = adaptedReferenceOriginalTarget != null - private val isKotlinFunInterface = - samSuperType != null && samSuperType.getClass()?.origin != IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB + private val samInterface = samSuperType?.getClass() + private val isKotlinFunInterface = samInterface != null && !samInterface.isFromJava() private val needToGenerateSamEqualsHashCodeMethods = isKotlinFunInterface && (isAdaptedReference || !isLambda) @@ -196,6 +196,14 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) context.ir.symbols.functionAdapter.defaultType else null, ) + if (samInterface != null && origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL) { + // Old back-end generates formal type parameters as in SAM supertype. + // Here we create formal type parameters with same names and equivalent upper bounds. + // We don't really perform any type substitutions within class body + // (it's all fine as soon as we have required generic signatures and don't fail anywhere). + // NB this would no longer matter if we generate SAM wrapper classes as synthetic. + typeParameters = createFakeFormalTypeParameters(samInterface.typeParameters, this) + } createImplicitParameterDeclarationWithWrappedDescriptor() copyAttributes(irFunctionReference) if (isLambda) { @@ -203,6 +211,24 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) } } + private fun createFakeFormalTypeParameters(sourceTypeParameters: List, irClass: IrClass): List { + if (sourceTypeParameters.isEmpty()) return emptyList() + + val fakeTypeParameters = sourceTypeParameters.map { + buildTypeParameter(irClass) { + updateFrom(it) + name = it.name + } + } + val typeRemapper = IrTypeParameterRemapper(sourceTypeParameters.associateWith { fakeTypeParameters[it.index] }) + for (fakeTypeParameter in fakeTypeParameters) { + val sourceTypeParameter = sourceTypeParameters[fakeTypeParameter.index] + fakeTypeParameter.superTypes = sourceTypeParameter.superTypes.map { typeRemapper.remapType(it) } + } + + return fakeTypeParameters + } + private val receiverField = context.ir.symbols.functionReferenceReceiverField.owner fun build(): IrExpression = context.createJvmIrBuilder(currentScope!!.scope.scopeOwnerSymbol).run { @@ -390,7 +416,11 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) isSuspend = callee.isSuspend }.apply { overriddenSymbols += superMethod - dispatchReceiverParameter = parentAsClass.thisReceiver!!.copyTo(this) + dispatchReceiverParameter = buildReceiverParameter( + this, + IrDeclarationOrigin.INSTANCE_RECEIVER, + functionReferenceClass.symbol.defaultType + ) if (isLambda) createLambdaInvokeMethod() else createFunctionReferenceInvokeMethod(receiverVar) } @@ -427,8 +457,9 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) // will put it into a field. if (samSuperType == null) irImplicitCast( - irGetField(irGet(dispatchReceiverParameter!!), - this@FunctionReferenceBuilder.receiverField + irGetField( + irGet(dispatchReceiverParameter!!), + this@FunctionReferenceBuilder.receiverField ), boundReceiver.second.type ) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt index 7eda3131c75..0fc45178264 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt @@ -1075,11 +1075,13 @@ private fun makeKotlinType( classDescriptor.defaultType.replace(newArguments = kotlinTypeArguments).makeNullableAsSpecified(hasQuestionMark) } catch (e: Throwable) { throw RuntimeException( - "Classifier: $classDescriptor\n" + + "Classifier: ${classifier.owner.render()}\n" + "Type parameters:\n" + classDescriptor.defaultType.constructor.parameters.withIndex() .joinToString(separator = "\n") { - "${it.index}: ${(it.value as IrBasedTypeParameterDescriptor).owner.render()}" + val irTypeParameter = (it.value as IrBasedTypeParameterDescriptor).owner + "${it.index}: ${irTypeParameter.render()} " + + "of ${irTypeParameter.parent.render()}" } + "\nType arguments:\n" + arguments.withIndex() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt index 00c2732e0cf..a7427edd14b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt @@ -18,8 +18,10 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.impl.* import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable +import org.jetbrains.kotlin.ir.util.isAnonymousObject import org.jetbrains.kotlin.ir.util.isPropertyAccessor import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.makeNullable @@ -177,6 +179,10 @@ val IrClass.typeConstructorParameters: Sequence // Ideally this should be fixed in FE. null } + current.isAnonymousObject -> { + // Anonymous classes don't capture type parameters. + null + } parent is IrClass && current is IrClass && !current.isInner -> null else -> diff --git a/compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt b/compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt new file mode 100644 index 00000000000..4d07619d049 --- /dev/null +++ b/compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt @@ -0,0 +1,17 @@ +fun interface FunIFace { + fun call(ic: T): R +} + +fun bar(value: T, f: FunIFace): R { + return f.call(value) +} + +class X(val value: Any) + +fun gfn(a: X): T = + bar(a) { + it.value as T + } + +fun box() = + gfn(X("OK")) \ No newline at end of file diff --git a/compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt b/compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt new file mode 100644 index 00000000000..4a8d1cbd019 --- /dev/null +++ b/compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt @@ -0,0 +1,8 @@ +fun test(): String { + val x = object { + fun foo() = "OK" + } + return x.foo() +} + +fun box() = test() \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.kt b/compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.kt new file mode 100644 index 00000000000..b7284b04c99 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.kt @@ -0,0 +1,18 @@ +// WITH_SIGNATURES + +fun test() { + val x = object { + fun foo() {} + + fun S2.ext() {} + + val S3.extVal + get() = 1 + + var S4.extVar + get() = 1 + set(value) {} + } + + x.foo() +} diff --git a/compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.txt b/compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.txt new file mode 100644 index 00000000000..d5bfd636f73 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.txt @@ -0,0 +1,19 @@ +@kotlin.Metadata +public final class AnonymousObjectInGenericFunKt$test$x$1 { + // source: 'anonymousObjectInGenericFun.kt' + public final <()V> method foo(): void + public final <(TS2;)V> method ext(p0: java.lang.Object): void + public final <(TS3;)I> method getExtVal(p0: java.lang.Object): int + public final <(TS4;)I> method getExtVar(p0: java.lang.Object): int + public final <(TS4;I)V> method setExtVar(p0: java.lang.Object, p1: int): void + method (): void + enclosing method AnonymousObjectInGenericFunKt.test()V + inner (anonymous) class AnonymousObjectInGenericFunKt$test$x$1 +} + +@kotlin.Metadata +public final class AnonymousObjectInGenericFunKt { + // source: 'anonymousObjectInGenericFun.kt' + public final static <()V> method test(): void + inner (anonymous) class AnonymousObjectInGenericFunKt$test$x$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt new file mode 100644 index 00000000000..5686fc2bcb1 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt @@ -0,0 +1,12 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun interface Sam { + fun get(): T +} + +fun expectsSam(sam: Sam) = sam.get() + +fun foo(): T = null!! + +fun genericSam(): T = expectsSam(::foo) diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.txt new file mode 100644 index 00000000000..1206f0318fa --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.txt @@ -0,0 +1,36 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +synthetic final class;> TKt$genericSam$1 { + // source: 't.kt' + public final <()TT;> method invoke(): java.lang.Object + static method (): void + method (): void + enclosing method TKt.genericSam()Ljava/lang/Object; + public final static field INSTANCE: TKt$genericSam$1 + inner (anonymous) class TKt$genericSam$1 +} + +@kotlin.Metadata +final class TKt$sam$Sam$0 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public method equals(p0: java.lang.Object): boolean + public synthetic final method get(): java.lang.Object + public method getFunctionDelegate(): kotlin.Function + public method hashCode(): int + private synthetic final field function: kotlin.jvm.functions.Function0 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <()TT;> method foo(): java.lang.Object + public final static <()TT;> method genericSam(): java.lang.Object + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + inner (anonymous) class TKt$genericSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface_ir.txt new file mode 100644 index 00000000000..810a0867f21 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface_ir.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +synthetic final class;Lkotlin/jvm/internal/FunctionAdapter;> TKt$genericSam$1 { + // source: 't.kt' + public final @org.jetbrains.annotations.NotNull <()Lkotlin/Function<*>;> method getFunctionDelegate(): kotlin.Function + public final <()TT;> method get(): java.lang.Object + static method (): void + method (): void + public final method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean + public final method hashCode(): int + enclosing method TKt.genericSam()Ljava/lang/Object; + public final static field INSTANCE: TKt$genericSam$1 + inner (anonymous) class TKt$genericSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <()TT;> method foo(): java.lang.Object + public final static <()TT;> method genericSam(): java.lang.Object + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + inner (anonymous) class TKt$genericSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt new file mode 100644 index 00000000000..0e255f086a2 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt @@ -0,0 +1,18 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun foo(): T = null!! + +fun genericSam(): T = J.g(::foo) + +// FILE: J.java +public class J { + static T g(Sam s) { + return s.get(); + } +} + +// FILE: Sam.java +public interface Sam { + T get(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.txt new file mode 100644 index 00000000000..84937e9c843 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.txt @@ -0,0 +1,26 @@ +@kotlin.Metadata +synthetic final class;> TKt$genericSam$1 { + // source: 't.kt' + public final <()TT;> method invoke(): java.lang.Object + static method (): void + method (): void + enclosing method TKt.genericSam()Ljava/lang/Object; + public final static field INSTANCE: TKt$genericSam$1 + inner (anonymous) class TKt$genericSam$1 +} + +@kotlin.Metadata +final class TKt$sam$Sam$0 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public synthetic final method get(): java.lang.Object + private synthetic final field function: kotlin.jvm.functions.Function0 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <()TT;> method foo(): java.lang.Object + public final static <()TT;> method genericSam(): java.lang.Object + inner (anonymous) class TKt$genericSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface_ir.txt new file mode 100644 index 00000000000..74131c30203 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface_ir.txt @@ -0,0 +1,18 @@ +@kotlin.Metadata +synthetic final class;> TKt$genericSam$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + static method (): void + method (): void + enclosing method TKt.genericSam()Ljava/lang/Object; + public final static field INSTANCE: TKt$genericSam$1 + inner (anonymous) class TKt$genericSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <()TT;> method foo(): java.lang.Object + public final static <()TT;> method genericSam(): java.lang.Object + inner (anonymous) class TKt$genericSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt new file mode 100644 index 00000000000..163b33e639e --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt @@ -0,0 +1,12 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun interface Sam { + fun get(): T +} + +fun expectsSam(sam: Sam) = sam.get() + +fun foo(): String = "" + +fun specializedSam(): String = expectsSam(::foo) diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.txt new file mode 100644 index 00000000000..9a609621556 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.txt @@ -0,0 +1,37 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +final class TKt$sam$Sam$0 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public method equals(p0: java.lang.Object): boolean + public synthetic final method get(): java.lang.Object + public method getFunctionDelegate(): kotlin.Function + public method hashCode(): int + private synthetic final field function: kotlin.jvm.functions.Function0 +} + +@kotlin.Metadata +synthetic final class;> TKt$specializedSam$1 { + // source: 't.kt' + static method (): void + method (): void + public synthetic bridge method invoke(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method invoke(): java.lang.String + enclosing method TKt.specializedSam()Ljava/lang/String; + public final static field INSTANCE: TKt$specializedSam$1 + inner (anonymous) class TKt$specializedSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method foo(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method specializedSam(): java.lang.String + inner (anonymous) class TKt$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface_ir.txt new file mode 100644 index 00000000000..5fc30d13306 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface_ir.txt @@ -0,0 +1,29 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +synthetic final class;Lkotlin/jvm/internal/FunctionAdapter;> TKt$specializedSam$1 { + // source: 't.kt' + public final @org.jetbrains.annotations.NotNull <()Lkotlin/Function<*>;> method getFunctionDelegate(): kotlin.Function + static method (): void + method (): void + public final method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean + public synthetic bridge method get(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method get(): java.lang.String + public final method hashCode(): int + enclosing method TKt.specializedSam()Ljava/lang/String; + public final static field INSTANCE: TKt$specializedSam$1 + inner (anonymous) class TKt$specializedSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + public final static @org.jetbrains.annotations.NotNull method foo(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method specializedSam(): java.lang.String + inner (anonymous) class TKt$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt new file mode 100644 index 00000000000..d403207631f --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt @@ -0,0 +1,18 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun foo(): String = "" + +fun specializedSam(): String = J.g(::foo) + +// FILE: J.java +public class J { + static T g(Sam s) { + return s.get(); + } +} + +// FILE: Sam.java +public interface Sam { + T get(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.txt new file mode 100644 index 00000000000..9bd3589ccdd --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.txt @@ -0,0 +1,27 @@ +@kotlin.Metadata +final class TKt$sam$Sam$0 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public synthetic final method get(): java.lang.Object + private synthetic final field function: kotlin.jvm.functions.Function0 +} + +@kotlin.Metadata +synthetic final class;> TKt$specializedSam$1 { + // source: 't.kt' + static method (): void + method (): void + public synthetic bridge method invoke(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method invoke(): java.lang.String + enclosing method TKt.specializedSam()Ljava/lang/String; + public final static field INSTANCE: TKt$specializedSam$1 + inner (anonymous) class TKt$specializedSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull method foo(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method specializedSam(): java.lang.String + inner (anonymous) class TKt$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface_ir.txt new file mode 100644 index 00000000000..b8aa2e40aec --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface_ir.txt @@ -0,0 +1,19 @@ +@kotlin.Metadata +synthetic final class;> TKt$specializedSam$1 { + // source: 't.kt' + static method (): void + method (): void + public synthetic bridge method get(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method get(): java.lang.String + enclosing method TKt.specializedSam()Ljava/lang/String; + public final static field INSTANCE: TKt$specializedSam$1 + inner (anonymous) class TKt$specializedSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull method foo(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method specializedSam(): java.lang.String + inner (anonymous) class TKt$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt new file mode 100644 index 00000000000..f41de2181c4 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt @@ -0,0 +1,10 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun interface Sam { + fun get(): T +} + +fun expectsSam(sam: Sam) = sam.get() + +fun genericSam(f: () -> T): T = expectsSam(f) diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.txt new file mode 100644 index 00000000000..af2dd62d6a2 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.txt @@ -0,0 +1,23 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +final class TKt$sam$Sam$0 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public method equals(p0: java.lang.Object): boolean + public synthetic final method get(): java.lang.Object + public method getFunctionDelegate(): kotlin.Function + public method hashCode(): int + private synthetic final field function: kotlin.jvm.functions.Function0 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt new file mode 100644 index 00000000000..82459ca38ac --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt @@ -0,0 +1,25 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +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 + 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 + private synthetic final field function: kotlin.jvm.functions.Function0 + final inner class TKt$sam$Sam$0 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object + final inner class TKt$sam$Sam$0 +} diff --git a/compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.kt b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt similarity index 85% rename from compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.kt rename to compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt index e62679359f9..edbb878fe04 100644 --- a/compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt @@ -1,5 +1,5 @@ // WITH_SIGNATURES -// FILE: samGenericSuperinterface.kt +// FILE: t.kt fun genericSam(f: () -> T): T = J.g(f) diff --git a/compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.txt b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.txt similarity index 69% rename from compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.txt rename to compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.txt index 95f7782207e..febf11f0f65 100644 --- a/compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.txt @@ -1,13 +1,13 @@ @kotlin.Metadata -final class SamGenericSuperinterfaceKt$sam$Sam$0 { - // source: 'samGenericSuperinterface.kt' +final class TKt$sam$Sam$0 { + // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method get(): java.lang.Object private synthetic final field function: kotlin.jvm.functions.Function0 } @kotlin.Metadata -public final class SamGenericSuperinterfaceKt { - // source: 'samGenericSuperinterface.kt' +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 } diff --git a/compiler/testData/codegen/bytecodeListing/samGenericSuperinterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface_ir.txt similarity index 60% rename from compiler/testData/codegen/bytecodeListing/samGenericSuperinterface_ir.txt rename to compiler/testData/codegen/bytecodeListing/sam/genericSamInterface_ir.txt index 96e17793796..8d415343607 100644 --- a/compiler/testData/codegen/bytecodeListing/samGenericSuperinterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface_ir.txt @@ -1,15 +1,15 @@ @kotlin.Metadata -final class SamGenericSuperinterfaceKt$sam$Sam$0 { - // source: 'samGenericSuperinterface.kt' +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 private synthetic final field function: kotlin.jvm.functions.Function0 - final inner class SamGenericSuperinterfaceKt$sam$Sam$0 + final inner class TKt$sam$Sam$0 } @kotlin.Metadata -public final class SamGenericSuperinterfaceKt { - // source: 'samGenericSuperinterface.kt' +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 - final inner class SamGenericSuperinterfaceKt$sam$Sam$0 + final inner class TKt$sam$Sam$0 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt new file mode 100644 index 00000000000..e06a76011af --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt @@ -0,0 +1,10 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun interface Sam { + fun get(): T +} + +fun expectsSam(sam: Sam) = sam.get() + +fun genericSamGet(f: () -> T): T = expectsSam({ f() }) diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.txt new file mode 100644 index 00000000000..7be23801bfd --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.txt @@ -0,0 +1,23 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + synthetic final field $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSamGet$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object + inner (anonymous) class TKt$genericSamGet$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt new file mode 100644 index 00000000000..58ebc83375c --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt @@ -0,0 +1,23 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSamGet$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object + inner (anonymous) class TKt$genericSamGet$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt new file mode 100644 index 00000000000..9720eeec38e --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt @@ -0,0 +1,22 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun genericSam(f: () -> T): Sam = J.sam({ f() }) + +fun genericSamGet(f: () -> T): T = J.get({ f() }) + +// FILE: J.java +public class J { + static T get(Sam s) { + return s.get(); + } + + static Sam sam(Sam s) { + return s; + } +} + +// FILE: Sam.java +public interface Sam { + T get(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.txt new file mode 100644 index 00000000000..76f84e30b1c --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSam$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSam(Lkotlin/jvm/functions/Function0;)LSam; + synthetic final field $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSam$1 +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + synthetic final field $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSamGet$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0<+TT;>;)LSam;> method genericSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): Sam + public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object + inner (anonymous) class TKt$genericSam$1 + inner (anonymous) class TKt$genericSamGet$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt new file mode 100644 index 00000000000..023cc600dfa --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt @@ -0,0 +1,28 @@ +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSam$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSam(Lkotlin/jvm/functions/Function0;)LSam; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSam$1 +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSamGet$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0<+TT;>;)LSam;> method genericSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): Sam + public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object + inner (anonymous) class TKt$genericSam$1 + inner (anonymous) class TKt$genericSamGet$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt new file mode 100644 index 00000000000..7e4453b74d6 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt @@ -0,0 +1,10 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun interface Sam { + fun get(): T +} + +fun expectsSam(sam: Sam) = sam.get() + +fun specializedSam(f: () -> String) = expectsSam({ f() }) diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.txt new file mode 100644 index 00000000000..f2ab0e8776b --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.txt @@ -0,0 +1,24 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public synthetic bridge method get(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method get(): java.lang.String + enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; + synthetic final field $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$specializedSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + inner (anonymous) class TKt$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt new file mode 100644 index 00000000000..8020d43de86 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt @@ -0,0 +1,24 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { + // source: 't.kt' + <(Lkotlin/jvm/functions/Function0;)V> method (p0: kotlin.jvm.functions.Function0): void + public synthetic bridge method get(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method get(): java.lang.String + enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$specializedSam$1 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + inner (anonymous) class TKt$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt new file mode 100644 index 00000000000..185c15d0e83 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt @@ -0,0 +1,16 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun specializedSam(f: () -> String) = J.g({ f() }) + +// FILE: J.java +public class J { + static T g(Sam s) { + return s.get(); + } +} + +// FILE: Sam.java +public interface Sam { + T get(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.txt new file mode 100644 index 00000000000..f5cdf682a05 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.txt @@ -0,0 +1,17 @@ +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public synthetic bridge method get(): java.lang.Object + public final method get(): java.lang.String + enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; + synthetic final field $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$specializedSam$1 +} + +@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$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt new file mode 100644 index 00000000000..9333ea1d30f --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt @@ -0,0 +1,17 @@ +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { + // source: 't.kt' + <(Lkotlin/jvm/functions/Function0;)V> method (p0: kotlin.jvm.functions.Function0): void + public synthetic bridge method get(): java.lang.Object + public final method get(): java.lang.String + enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$specializedSam$1 +} + +@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$specializedSam$1 +} diff --git a/compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt similarity index 100% rename from compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt rename to compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt diff --git a/compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.txt b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.txt similarity index 100% rename from compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.txt rename to compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.txt diff --git a/compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt similarity index 100% rename from compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne_ir.txt rename to compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt new file mode 100644 index 00000000000..150cd5d58d4 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt @@ -0,0 +1,10 @@ +// WITH_SIGNATURES +// FILE: t.kt + +fun interface Sam { + fun get(): T +} + +fun expectsSam(sam: Sam) = sam.get() + +fun specializedSam(f: () -> String) = expectsSam(f) diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.txt new file mode 100644 index 00000000000..6edd416e201 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.txt @@ -0,0 +1,23 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +final class TKt$sam$Sam$0 { + // source: 't.kt' + method (p0: kotlin.jvm.functions.Function0): void + public method equals(p0: java.lang.Object): boolean + public synthetic final method get(): java.lang.Object + public method getFunctionDelegate(): kotlin.Function + public method hashCode(): int + private synthetic final field function: kotlin.jvm.functions.Function0 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt new file mode 100644 index 00000000000..e08ff5f90d4 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt @@ -0,0 +1,25 @@ +@kotlin.Metadata +public interface<Ljava/lang/Object;> Sam { + // source: 't.kt' + public abstract <()TT;> method get(): java.lang.Object +} + +@kotlin.Metadata +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 + 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 + private synthetic final field function: kotlin.jvm.functions.Function0 + final inner class TKt$sam$Sam$0 +} + +@kotlin.Metadata +public final class TKt { + // source: 't.kt' + public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String + public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + final inner class TKt$sam$Sam$0 +} diff --git a/compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.kt b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt similarity index 85% rename from compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.kt rename to compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt index 5d2290fba45..72ecaa94f56 100644 --- a/compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt @@ -1,5 +1,5 @@ // WITH_SIGNATURES -// FILE: samGenericSuperinterface.kt +// FILE: t.kt fun specializedSam(f: () -> String) = J.g(f) diff --git a/compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.txt similarity index 69% rename from compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.txt rename to compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.txt index da97bd5cec5..c52afa8868a 100644 --- a/compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.txt @@ -1,13 +1,13 @@ @kotlin.Metadata -final class SamGenericSuperinterfaceKt$sam$Sam$0 { - // source: 'samGenericSuperinterface.kt' +final class TKt$sam$Sam$0 { + // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method get(): java.lang.Object private synthetic final field function: kotlin.jvm.functions.Function0 } @kotlin.Metadata -public final class SamGenericSuperinterfaceKt { - // source: 'samGenericSuperinterface.kt' +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 } diff --git a/compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface_ir.txt similarity index 60% rename from compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface_ir.txt rename to compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface_ir.txt index 25f44905b2a..2224df22c30 100644 --- a/compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface_ir.txt @@ -1,15 +1,15 @@ @kotlin.Metadata -final class SamGenericSuperinterfaceKt$sam$Sam$0 { - // source: 'samGenericSuperinterface.kt' +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 private synthetic final field function: kotlin.jvm.functions.Function0 - final inner class SamGenericSuperinterfaceKt$sam$Sam$0 + final inner class TKt$sam$Sam$0 } @kotlin.Metadata -public final class SamGenericSuperinterfaceKt { - // source: 'samGenericSuperinterface.kt' +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 - final inner class SamGenericSuperinterfaceKt$sam$Sam$0 + final inner class TKt$sam$Sam$0 } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 67a85554678..491fd945ca5 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -12178,6 +12178,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("subtypeOfFunctionalTypeToFunInterfaceConversion.kt") public void testSubtypeOfFunctionalTypeToFunInterfaceConversion() throws Exception { runTest("compiler/testData/codegen/box/funInterface/subtypeOfFunctionalTypeToFunInterfaceConversion.kt"); @@ -15922,6 +15927,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt"); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index d396a68e870..a0df878ef93 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -39,6 +39,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("callableNameIntrinsic.kt") public void testCallableNameIntrinsic() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/callableNameIntrinsic.kt"); @@ -209,21 +214,6 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/rawTypeInSignature.kt"); } - @TestMetadata("samAdapterAndInlinedOne.kt") - public void testSamAdapterAndInlinedOne() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt"); - } - - @TestMetadata("samGenericSuperinterface.kt") - public void testSamGenericSuperinterface() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.kt"); - } - - @TestMetadata("samSpecializedGenericSuperinterface.kt") - public void testSamSpecializedGenericSuperinterface() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.kt"); - } - @TestMetadata("varargsBridge.kt") public void testVarargsBridge() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/varargsBridge.kt"); @@ -1495,6 +1485,84 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { } } + @TestMetadata("compiler/testData/codegen/bytecodeListing/sam") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Sam extends AbstractBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInSam() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("callableRefGenericFunInterface.kt") + public void testCallableRefGenericFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt"); + } + + @TestMetadata("callableRefGenericSamInterface.kt") + public void testCallableRefGenericSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt"); + } + + @TestMetadata("callableRefSpecializedFunInterface.kt") + public void testCallableRefSpecializedFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt"); + } + + @TestMetadata("callableRefSpecializedSamInterface.kt") + public void testCallableRefSpecializedSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt"); + } + + @TestMetadata("genericFunInterface.kt") + public void testGenericFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt"); + } + + @TestMetadata("genericSamInterface.kt") + public void testGenericSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt"); + } + + @TestMetadata("lambdaGenericFunInterface.kt") + public void testLambdaGenericFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt"); + } + + @TestMetadata("lambdaGenericSamInterface.kt") + public void testLambdaGenericSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt"); + } + + @TestMetadata("lambdaSpecializedFunInterface.kt") + public void testLambdaSpecializedFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt"); + } + + @TestMetadata("lambdaSpecializedSamInterface.kt") + public void testLambdaSpecializedSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt"); + } + + @TestMetadata("samAdapterAndInlinedOne.kt") + public void testSamAdapterAndInlinedOne() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt"); + } + + @TestMetadata("specializedFunInterface.kt") + public void testSpecializedFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt"); + } + + @TestMetadata("specializedSamInterface.kt") + public void testSpecializedSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt"); + } + } + @TestMetadata("compiler/testData/codegen/bytecodeListing/specialBridges") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3d89f468b2a..3bf118dd06e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12178,6 +12178,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("subtypeOfFunctionalTypeToFunInterfaceConversion.kt") public void testSubtypeOfFunctionalTypeToFunInterfaceConversion() throws Exception { runTest("compiler/testData/codegen/box/funInterface/subtypeOfFunctionalTypeToFunInterfaceConversion.kt"); @@ -15922,6 +15927,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt"); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 5c2dee7064d..ed92c4b4efc 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -12178,6 +12178,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("subtypeOfFunctionalTypeToFunInterfaceConversion.kt") public void testSubtypeOfFunctionalTypeToFunInterfaceConversion() throws Exception { runTest("compiler/testData/codegen/box/funInterface/subtypeOfFunctionalTypeToFunInterfaceConversion.kt"); @@ -15922,6 +15927,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt"); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 55440bc1093..ee3806fb430 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -39,6 +39,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("callableNameIntrinsic.kt") public void testCallableNameIntrinsic() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/callableNameIntrinsic.kt"); @@ -209,21 +214,6 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/rawTypeInSignature.kt"); } - @TestMetadata("samAdapterAndInlinedOne.kt") - public void testSamAdapterAndInlinedOne() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/samAdapterAndInlinedOne.kt"); - } - - @TestMetadata("samGenericSuperinterface.kt") - public void testSamGenericSuperinterface() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/samGenericSuperinterface.kt"); - } - - @TestMetadata("samSpecializedGenericSuperinterface.kt") - public void testSamSpecializedGenericSuperinterface() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/samSpecializedGenericSuperinterface.kt"); - } - @TestMetadata("varargsBridge.kt") public void testVarargsBridge() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/varargsBridge.kt"); @@ -1495,6 +1485,84 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes } } + @TestMetadata("compiler/testData/codegen/bytecodeListing/sam") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Sam extends AbstractIrBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInSam() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("callableRefGenericFunInterface.kt") + public void testCallableRefGenericFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt"); + } + + @TestMetadata("callableRefGenericSamInterface.kt") + public void testCallableRefGenericSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt"); + } + + @TestMetadata("callableRefSpecializedFunInterface.kt") + public void testCallableRefSpecializedFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt"); + } + + @TestMetadata("callableRefSpecializedSamInterface.kt") + public void testCallableRefSpecializedSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt"); + } + + @TestMetadata("genericFunInterface.kt") + public void testGenericFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt"); + } + + @TestMetadata("genericSamInterface.kt") + public void testGenericSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt"); + } + + @TestMetadata("lambdaGenericFunInterface.kt") + public void testLambdaGenericFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt"); + } + + @TestMetadata("lambdaGenericSamInterface.kt") + public void testLambdaGenericSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt"); + } + + @TestMetadata("lambdaSpecializedFunInterface.kt") + public void testLambdaSpecializedFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt"); + } + + @TestMetadata("lambdaSpecializedSamInterface.kt") + public void testLambdaSpecializedSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt"); + } + + @TestMetadata("samAdapterAndInlinedOne.kt") + public void testSamAdapterAndInlinedOne() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt"); + } + + @TestMetadata("specializedFunInterface.kt") + public void testSpecializedFunInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt"); + } + + @TestMetadata("specializedSamInterface.kt") + public void testSpecializedSamInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt"); + } + } + @TestMetadata("compiler/testData/codegen/bytecodeListing/specialBridges") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index ee15ec8ed6a..34ca7cbeb78 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -10408,6 +10408,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("subtypeOfFunctionalTypeToFunInterfaceConversion.kt") public void testSubtypeOfFunctionalTypeToFunInterfaceConversion() throws Exception { runTest("compiler/testData/codegen/box/funInterface/subtypeOfFunctionalTypeToFunInterfaceConversion.kt"); @@ -13752,6 +13757,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt"); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index e77006fe787..3feb9e3640c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -10408,6 +10408,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("subtypeOfFunctionalTypeToFunInterfaceConversion.kt") public void testSubtypeOfFunctionalTypeToFunInterfaceConversion() throws Exception { runTest("compiler/testData/codegen/box/funInterface/subtypeOfFunctionalTypeToFunInterfaceConversion.kt"); @@ -13752,6 +13757,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt"); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 1ff50fac443..95c1521dc26 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -10408,6 +10408,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("subtypeOfFunctionalTypeToFunInterfaceConversion.kt") public void testSubtypeOfFunctionalTypeToFunInterfaceConversion() throws Exception { runTest("compiler/testData/codegen/box/funInterface/subtypeOfFunctionalTypeToFunInterfaceConversion.kt"); @@ -13817,6 +13822,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/ir/anonymousObjectInForLoopIteratorAndBody.kt"); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 91a8b9f0785..86c26a57ad7 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -5259,6 +5259,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/funInterface/samConstructorExplicitInvocation.kt"); } + @TestMetadata("samConversionToGenericInterfaceInGenericFun.kt") + public void testSamConversionToGenericInterfaceInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/samConversionToGenericInterfaceInGenericFun.kt"); + } + @TestMetadata("compiler/testData/codegen/box/funInterface/equality") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -8043,6 +8048,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + @TestMetadata("anonymousObjectInGenericFun.kt") + public void testAnonymousObjectInGenericFun() throws Exception { + runTest("compiler/testData/codegen/box/ir/anonymousObjectInGenericFun.kt"); + } + @TestMetadata("anonymousObjectInsideElvis.kt") public void testAnonymousObjectInsideElvis() throws Exception { runTest("compiler/testData/codegen/box/ir/anonymousObjectInsideElvis.kt");