From e6c089ef40abd03ced62daf368d4183a32852530 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 9 Apr 2021 15:26:47 +0200 Subject: [PATCH] IR: fix SAM conversion for types with contravariant intersection argument type In the added test, the problem was that the SAM type as computed by `SamTypeFactory.createByValueParameter` was `Consumer<{BaseClass & BaseInterface}>`, which was latter approximated in psi2ir during the KotlinType->IrType conversion to `Consumer` (here: https://github.com/JetBrains/kotlin/blob/3034d9d791cf1f9033104e12448e0d262d3bc3ce/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt#L606), because intersection type argument is approximated to `out Any?`. To avoid this, replace intersection type in immediate arguments of a SAM type with the common supertype of its components at the same place where we're getting rid of projections. #KT-45945 Fixed --- .../kotlin/backend/common/SamType.kt | 14 +++++- .../kotlin/codegen/state/typeMapperUtils.kt | 5 -- .../FirBlackBoxCodegenTestGenerated.java | 36 +++++++++++++++ .../contravariantIntersectionType.kt | 38 +++++++++++++++ ...ectionTypeWithNonTrivialCommonSupertype.kt | 42 +++++++++++++++++ ...ctionTypeWithNonTrivialCommonSupertype2.kt | 34 ++++++++++++++ .../box/sam/contravariantIntersectionType.kt | 42 +++++++++++++++++ ...ectionTypeWithNonTrivialCommonSupertype.kt | 46 +++++++++++++++++++ ...ctionTypeWithNonTrivialCommonSupertype2.kt | 38 +++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 36 +++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 36 +++++++++++++++ .../LightAnalysisModeTestGenerated.java | 30 ++++++++++++ .../IrJsCodegenBoxES6TestGenerated.java | 15 ++++++ .../IrJsCodegenBoxTestGenerated.java | 15 ++++++ .../semantics/JsCodegenBoxTestGenerated.java | 15 ++++++ .../IrCodegenBoxWasmTestGenerated.java | 15 ++++++ 16 files changed, 450 insertions(+), 7 deletions(-) create mode 100644 compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt create mode 100644 compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt create mode 100644 compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt create mode 100644 compiler/testData/codegen/box/sam/contravariantIntersectionType.kt create mode 100644 compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt create mode 100644 compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/SamType.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/SamType.kt index 06c8d9f0360..5426b332d96 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/SamType.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/SamType.kt @@ -9,6 +9,8 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator +import org.jetbrains.kotlin.resolve.calls.commonSuperType import org.jetbrains.kotlin.resolve.sam.getAbstractMembers import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithNothing @@ -80,11 +82,19 @@ open class SamTypeFactory { } private fun KotlinType.removeExternalProjections(): KotlinType { - val newArguments = arguments.map { TypeProjectionImpl(Variance.INVARIANT, it.type) } + val newArguments = arguments.map { + val type = it.type + TypeProjectionImpl( + Variance.INVARIANT, + if (type.constructor is IntersectionTypeConstructor) + NewCommonSuperTypeCalculator.commonSuperType(type.constructor.supertypes.map(KotlinType::unwrap)) + else type + ) + } return replace(newArguments) } companion object { val INSTANCE = SamTypeFactory() } -} \ No newline at end of file +} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMapperUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMapperUtils.kt index 1be180c7b03..62663477415 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMapperUtils.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/typeMapperUtils.kt @@ -87,11 +87,6 @@ fun CallableMemberDescriptor.createTypeParameterWithNewName( return newDescriptor } -fun KotlinType.removeExternalProjections(): KotlinType { - val newArguments = arguments.map { TypeProjectionImpl(Variance.INVARIANT, it.type) } - return replace(newArguments) -} - fun isInlineClassConstructorAccessor(descriptor: FunctionDescriptor): Boolean = descriptor is AccessorForConstructorDescriptor && descriptor.calleeDescriptor.constructedClass.isInlineClass() diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 8f02476191f..a66aa06478d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -15446,6 +15446,24 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/funInterface/castFromAny.kt"); } + @Test + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @Test @TestMetadata("funConversionInVararg.kt") public void testFunConversionInVararg() throws Exception { @@ -37754,6 +37772,24 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/sam/castFromAny.kt"); } + @Test + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionType.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @Test @TestMetadata("differentFqNames.kt") public void testDifferentFqNames() throws Exception { diff --git a/compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt b/compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt new file mode 100644 index 00000000000..e8990d132fc --- /dev/null +++ b/compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt @@ -0,0 +1,38 @@ +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: SAM_CONVERSIONS + +// CHECK_BYTECODE_TEXT +// 0 java/lang/invoke/LambdaMetafactory + +abstract class BaseClass +interface BaseInterface + +class ConcreteType : BaseClass(), BaseInterface +class ConcreteType2 : BaseClass(), BaseInterface + +fun box(): String { + example(0) + return "OK" +} + +fun example(input: Int) { + val instance = when (input) { + 0 -> GenericHolder() + else -> GenericHolder() + } + + instance.doOnSuccess {} + instance.doOnSuccess(::functionReference) +} + +fun functionReference(x: Any) {} + +class GenericHolder { + fun doOnSuccess(onSuccess: Consumer) { + onSuccess.accept(object : BaseClass() {} as T) + } +} + +fun interface Consumer { + fun accept(t: T) +} diff --git a/compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt b/compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt new file mode 100644 index 00000000000..9debee20f81 --- /dev/null +++ b/compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt @@ -0,0 +1,42 @@ +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: SAM_CONVERSIONS + +// CHECK_BYTECODE_TEXT +// 0 java/lang/invoke/LambdaMetafactory + +interface Top + +interface Common : Top + +abstract class BaseClass : Common +interface BaseInterface : Common + +class ConcreteType : BaseClass(), BaseInterface +class ConcreteType2 : BaseClass(), BaseInterface + +fun box(): String { + example(0) + return "OK" +} + +fun example(input: Int) { + val instance = when (input) { + 0 -> GenericHolder() + else -> GenericHolder() + } + + instance.doOnSuccess {} + instance.doOnSuccess(::functionReference) +} + +fun functionReference(x: Any) {} + +class GenericHolder { + fun doOnSuccess(onSuccess: Consumer) { + onSuccess.accept(object : BaseClass() {} as T) + } +} + +fun interface Consumer { + fun accept(t: T) +} diff --git a/compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt b/compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt new file mode 100644 index 00000000000..7eed37f0771 --- /dev/null +++ b/compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt @@ -0,0 +1,34 @@ +// IGNORE_BACKEND: WASM +// WASM_MUTE_REASON: SAM_CONVERSIONS + +// CHECK_BYTECODE_TEXT +// 0 java/lang/invoke/LambdaMetafactory + +interface Top +interface Unrelated + +interface A : Top, Unrelated +interface B : Top, Unrelated + +fun box(): String { + val g = when ("".length) { + 0 -> G() + else -> G() + } + + g.check {} + g.check(::functionReference) + return "OK" +} + +fun functionReference(x: Any) {} + +class G { + fun check(x: IFoo) { + x.accept(object : A {} as T) + } +} + +fun interface IFoo { + fun accept(t: T) +} diff --git a/compiler/testData/codegen/box/sam/contravariantIntersectionType.kt b/compiler/testData/codegen/box/sam/contravariantIntersectionType.kt new file mode 100644 index 00000000000..5d654582f91 --- /dev/null +++ b/compiler/testData/codegen/box/sam/contravariantIntersectionType.kt @@ -0,0 +1,42 @@ +// TARGET_BACKEND: JVM + +// CHECK_BYTECODE_TEXT +// JVM_IR_TEMPLATES +// 2 java/lang/invoke/LambdaMetafactory + +// FILE: test.kt + +abstract class BaseClass +interface BaseInterface + +class ConcreteType : BaseClass(), BaseInterface +class ConcreteType2 : BaseClass(), BaseInterface + +fun box(): String { + example(0) + return "OK" +} + +fun example(input: Int) { + val instance = when (input) { + 0 -> GenericHolder() + else -> GenericHolder() + } + + instance.doOnSuccess {} + instance.doOnSuccess(::functionReference) +} + +fun functionReference(x: Any) {} + +class GenericHolder { + fun doOnSuccess(onSuccess: Consumer) { + onSuccess.accept(object : BaseClass() {} as T) + } +} + +// FILE: Consumer.java + +public interface Consumer { + void accept(T t); +} diff --git a/compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt b/compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt new file mode 100644 index 00000000000..53735cc98dc --- /dev/null +++ b/compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt @@ -0,0 +1,46 @@ +// TARGET_BACKEND: JVM + +// CHECK_BYTECODE_TEXT +// JVM_IR_TEMPLATES +// 2 java/lang/invoke/LambdaMetafactory + +// FILE: test.kt + +interface Top + +interface Common : Top + +abstract class BaseClass : Common +interface BaseInterface : Common + +class ConcreteType : BaseClass(), BaseInterface +class ConcreteType2 : BaseClass(), BaseInterface + +fun box(): String { + example(0) + return "OK" +} + +fun example(input: Int) { + val instance = when (input) { + 0 -> GenericHolder() + else -> GenericHolder() + } + + instance.doOnSuccess {} + instance.doOnSuccess(::functionReference) +} + +fun functionReference(x: Any) {} + +class GenericHolder { + fun doOnSuccess(onSuccess: Consumer) { + onSuccess.accept(object : BaseClass() {} as T) + } +} + +// FILE: Consumer.java + +public interface Consumer { + void accept(T t); +} diff --git a/compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt b/compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt new file mode 100644 index 00000000000..0bde6aa4569 --- /dev/null +++ b/compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt @@ -0,0 +1,38 @@ +// TARGET_BACKEND: JVM + +// CHECK_BYTECODE_TEXT +// JVM_IR_TEMPLATES +// 2 java/lang/invoke/LambdaMetafactory + +// FILE: test.kt + +interface Top +interface Unrelated + +interface A : Top, Unrelated +interface B : Top, Unrelated + +fun box(): String { + val g = when ("".length) { + 0 -> G() + else -> G() + } + + g.check {} + g.check(::functionReference) + return "OK" +} + +fun functionReference(x: Any) {} + +class G { + fun check(x: IFoo) { + x.accept(object : A {} as T) + } +} + +// FILE: IFoo.java + +public interface IFoo { + void accept(T t); +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 59de5b9853e..82f04814459 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -15422,6 +15422,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/funInterface/castFromAny.kt"); } + @Test + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @Test @TestMetadata("funConversionInVararg.kt") public void testFunConversionInVararg() throws Exception { @@ -37730,6 +37748,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/sam/castFromAny.kt"); } + @Test + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionType.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @Test @TestMetadata("differentFqNames.kt") public void testDifferentFqNames() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index af61d1f8a76..0bb70cb495a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -15446,6 +15446,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/funInterface/castFromAny.kt"); } + @Test + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @Test @TestMetadata("funConversionInVararg.kt") public void testFunConversionInVararg() throws Exception { @@ -37754,6 +37772,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/sam/castFromAny.kt"); } + @Test + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionType.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @Test + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @Test @TestMetadata("differentFqNames.kt") public void testDifferentFqNames() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index af620100757..58008671fe7 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12721,6 +12721,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/funInterface/castFromAny.kt"); } + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @TestMetadata("funConversionInVararg.kt") public void testFunConversionInVararg() throws Exception { runTest("compiler/testData/codegen/box/funInterface/funConversionInVararg.kt"); @@ -30107,6 +30122,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/sam/castFromAny.kt"); } + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionType.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/sam/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @TestMetadata("differentFqNames.kt") public void testDifferentFqNames() throws Exception { runTest("compiler/testData/codegen/box/sam/differentFqNames.kt"); 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 5cf0d734993..cd4a5ff8c64 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 @@ -11225,6 +11225,21 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/funInterface/castFromAny.kt"); } + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @TestMetadata("funConversionInVararg.kt") public void testFunConversionInVararg() throws Exception { runTest("compiler/testData/codegen/box/funInterface/funConversionInVararg.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 77a9d04c1bf..f3cec2965ac 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 @@ -10646,6 +10646,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/funInterface/castFromAny.kt"); } + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @TestMetadata("funConversionInVararg.kt") public void testFunConversionInVararg() throws Exception { runTest("compiler/testData/codegen/box/funInterface/funConversionInVararg.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 b582707be3a..98ebb160863 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 @@ -10646,6 +10646,21 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/funInterface/castFromAny.kt"); } + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @TestMetadata("funConversionInVararg.kt") public void testFunConversionInVararg() throws Exception { runTest("compiler/testData/codegen/box/funInterface/funConversionInVararg.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 377cd120450..3b063cb3c03 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 @@ -5371,6 +5371,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/funInterface/basicFunInterface.kt"); } + @TestMetadata("contravariantIntersectionType.kt") + public void testContravariantIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionType.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype.kt"); + } + + @TestMetadata("contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt") + public void testContravariantIntersectionTypeWithNonTrivialCommonSupertype2() throws Exception { + runTest("compiler/testData/codegen/box/funInterface/contravariantIntersectionTypeWithNonTrivialCommonSupertype2.kt"); + } + @TestMetadata("compiler/testData/codegen/box/funInterface/equality") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)