From 9366847e966c4bbb0bbe814bfa967ac14cafb914 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 16 Oct 2023 13:19:40 +0300 Subject: [PATCH] [FIR2IR] Properly approximate intersection types during fir2ir conversion ^KT-62544 Fixed --- .../kotlin/fir/backend/Fir2IrTypeConverter.kt | 7 +- ...LightTreeBlackBoxCodegenTestGenerated.java | 6 + ...hIrFakeOverrideGeneratorTestGenerated.java | 6 + .../FirPsiBlackBoxCodegenTestGenerated.java | 6 + .../psi2ir/generators/TypeTranslatorImpl.kt | 10 +- .../types/TypeApproximatorConfiguration.kt | 7 + .../delegationToIntersectionType.fir.ir.txt | 12 +- .../delegationToIntersectionType2.fir.ir.txt | 12 +- .../intersectionWithInvisibleComponent.kt | 40 +++ .../sam/nonApproxToValidSupertype.fir.txt | 51 ---- .../sam/nonApproxToValidSupertype.kt | 3 - .../sam/nonApproxToValidSupertype2.fir.txt | 62 ----- .../sam/nonApproxToValidSupertype2.kt | 3 - .../ir/irText/expressions/bangbang.fir.ir.txt | 12 +- .../ir/irText/expressions/bangbang.fir.kt.txt | 5 +- .../caoWithAdaptationForSam.fir.ir.txt | 17 +- .../caoWithAdaptationForSam.fir.kt.txt | 4 +- .../samConversionsWithSmartCasts.fir.ir.txt | 17 +- .../samConversionsWithSmartCasts.fir.kt.txt | 14 +- .../implicitCastToTypeParameter.fir.ir.txt | 4 +- .../implicitCastToTypeParameter.fir.kt.txt | 2 +- ...dReferenceWithIntersectionTypes.fir.ir.txt | 20 +- ...dReferenceWithIntersectionTypes.fir.kt.txt | 12 +- .../expressions/multipleSmartCasts.fir.ir.txt | 6 +- .../expressions/multipleSmartCasts.fir.kt.txt | 5 +- .../samConversionsWithSmartCasts.fir.ir.txt | 15 +- .../samConversionsWithSmartCasts.fir.kt.txt | 12 +- .../smartCastsWithDestructuring.fir.ir.txt | 6 +- .../smartCastsWithDestructuring.fir.kt.txt | 6 +- ...ConversionOnArbitraryExpression.fir.ir.txt | 4 +- ...ConversionOnArbitraryExpression.fir.kt.txt | 5 +- .../ir/irText/firProblems/Modality.fir.ir.txt | 170 ++++++++++++ .../ir/irText/firProblems/Modality.fir.kt.txt | 71 ++++++ .../ir/irText/firProblems/Modality.kt | 1 - .../firProblems/candidateSymbol.fir.ir.txt | 8 +- .../firProblems/candidateSymbol.fir.kt.txt | 3 +- .../irText/types/intersectionType2.fir.ir.txt | 105 -------- .../irText/types/intersectionType2.fir.kt.txt | 42 --- .../ir/irText/types/intersectionType2.kt | 1 + .../intersectionTypeInSamType.fir.ir.txt | 241 ------------------ .../irText/types/intersectionTypeInSamType.kt | 1 + .../ir/irText/types/kt49526.fir.ir.txt | 15 -- compiler/testData/ir/irText/types/kt49526.kt | 1 + ...localVariableOfIntersectionType.fir.ir.txt | 123 --------- ...localVariableOfIntersectionType.fir.kt.txt | 32 --- .../types/localVariableOfIntersectionType.kt | 1 + .../receiverOfIntersectionType.fir.ir.txt | 19 +- .../receiverOfIntersectionType.fir.kt.txt | 9 +- .../IrBlackBoxCodegenTestGenerated.java | 6 + ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 5 + ...TypeInLambdaLiteralAndDelegatedProperty.kt | 2 - 52 files changed, 450 insertions(+), 803 deletions(-) create mode 100644 compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt delete mode 100644 compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.fir.txt delete mode 100644 compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/types/intersectionType2.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/types/intersectionType2.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/types/intersectionTypeInSamType.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/types/kt49526.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.kt.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index f8362b627ab..343f3b08fed 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -234,8 +234,11 @@ class Fir2IrTypeConverter( original.toIrType(typeOrigin).makeNotNull() } is ConeIntersectionType -> { - // TODO: add intersectionTypeApproximation - intersectedTypes.first().toIrType(typeOrigin) + val approximated = session.typeApproximator.approximateToSuperType( + this, + TypeApproximatorConfiguration.FrontendToBackendTypesApproximation + )!! + approximated.toIrType(typeOrigin) } is ConeStubType -> createErrorType() is ConeIntegerLiteralType -> createErrorType() diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index f310e65f239..9ebe3f01608 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -21025,6 +21025,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); } + @Test + @TestMetadata("intersectionWithInvisibleComponent.kt") + public void testIntersectionWithInvisibleComponent() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index 37d01cd18b7..fe956fe82de 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -21025,6 +21025,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); } + @Test + @TestMetadata("intersectionWithInvisibleComponent.kt") + public void testIntersectionWithInvisibleComponent() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 71ffe95a435..2beec329f03 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -21025,6 +21025,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); } + @Test + @TestMetadata("intersectionWithInvisibleComponent.kt") + public void testIntersectionWithInvisibleComponent() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TypeTranslatorImpl.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TypeTranslatorImpl.kt index b57e4aac693..eb4937ce7da 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TypeTranslatorImpl.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/TypeTranslatorImpl.kt @@ -29,17 +29,9 @@ class TypeTranslatorImpl( private val typeApproximatorForNI = TypeApproximator(moduleDescriptor.builtIns, languageVersionSettings) - private val typeApproximatorConfiguration = - object : TypeApproximatorConfiguration.AllFlexibleSameValue() { - override val allFlexible: Boolean get() = true - override val errorType: Boolean get() = true - override val integerLiteralConstantType: Boolean get() = true - override val intersectionTypesInContravariantPositions: Boolean get() = true - } - override fun approximateType(type: KotlinType): KotlinType = substituteAlternativesInPublicType(type).let { - typeApproximatorForNI.approximateToSuperType(it, typeApproximatorConfiguration) ?: it + typeApproximatorForNI.approximateToSuperType(it, TypeApproximatorConfiguration.FrontendToBackendTypesApproximation) ?: it } override fun commonSupertype(types: Collection): KotlinType = diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt index 35dcca9a0a5..72451d66a6c 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt @@ -133,4 +133,11 @@ open class TypeApproximatorConfiguration { override val allFlexible: Boolean get() = true override val intersection: IntersectionStrategy = IntersectionStrategy.TO_UPPER_BOUND_IF_SUPERTYPE } + + object FrontendToBackendTypesApproximation : AllFlexibleSameValue() { + override val allFlexible: Boolean get() = true + override val errorType: Boolean get() = true + override val integerLiteralConstantType: Boolean get() = true + override val intersectionTypesInContravariantPositions: Boolean get() = true + } } diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType.fir.ir.txt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.fir.ir.txt index 8e43fd409bd..20b3f706f6a 100644 --- a/compiler/testData/codegen/box/delegation/delegationToIntersectionType.fir.ir.txt +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.fir.ir.txt @@ -100,9 +100,9 @@ FILE fqName: fileName:/delegationToIntersectionType.kt VALUE_PARAMETER name:c index:0 type:.C VALUE_PARAMETER name:d index:1 type:.D BLOCK_BODY - VAR name:intersection type:.A [val] - CALL 'public final fun select (a: T of .select, b: T of .select): T of .select declared in ' type=.A origin=null - : .A + VAR name:intersection type:kotlin.Any [val] + CALL 'public final fun select (a: T of .select, b: T of .select): T of .select declared in ' type=kotlin.Any origin=null + : kotlin.Any a: GET_VAR 'c: .C declared in .test' type=.C origin=null b: GET_VAR 'd: .D declared in .test' type=.D origin=null RETURN type=kotlin.Nothing from='public final fun test (c: .C, d: .D): kotlin.String declared in ' @@ -114,9 +114,9 @@ FILE fqName: fileName:/delegationToIntersectionType.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.B]' - FIELD DELEGATE name:$$delegate_0 type:.A visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:kotlin.Any visibility:private [final] EXPRESSION_BODY - GET_VAR 'val intersection: .A declared in .test' type=.A origin=null + GET_VAR 'val intersection: kotlin.Any declared in .test' type=kotlin.Any origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.test.) returnType:kotlin.String overridden: public abstract fun foo (): kotlin.String declared in .B @@ -125,7 +125,7 @@ FILE fqName: fileName:/delegationToIntersectionType.kt RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .test.' CALL 'public abstract fun foo (): kotlin.String declared in .B' type=kotlin.String origin=null $this: TYPE_OP type=.B origin=IMPLICIT_CAST typeOperand=.B - GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.A visibility:private [final]' type=.A origin=null + GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null receiver: GET_VAR ': .test. declared in .test..foo' type=.test. origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.fir.ir.txt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.fir.ir.txt index ee7af4d90d7..15aac97d855 100644 --- a/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.fir.ir.txt +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.fir.ir.txt @@ -104,9 +104,9 @@ FILE fqName: fileName:/delegationToIntersectionType2.kt VALUE_PARAMETER name:c index:0 type:.C VALUE_PARAMETER name:d index:1 type:.D BLOCK_BODY - VAR name:intersection type:.A [val] - CALL 'public final fun select (a: T of .select, b: T of .select): T of .select declared in ' type=.A origin=null - : .A + VAR name:intersection type:kotlin.Any [val] + CALL 'public final fun select (a: T of .select, b: T of .select): T of .select declared in ' type=kotlin.Any origin=null + : kotlin.Any a: GET_VAR 'c: .C declared in .test' type=.C origin=null b: GET_VAR 'd: .D declared in .test' type=.D origin=null RETURN type=kotlin.Nothing from='public final fun test (c: .C, d: .D): kotlin.String declared in ' @@ -119,9 +119,9 @@ FILE fqName: fileName:/delegationToIntersectionType2.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.A]' - FIELD DELEGATE name:$$delegate_0 type:.A visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:kotlin.Any visibility:private [final] EXPRESSION_BODY - GET_VAR 'val intersection: .A declared in .test' type=.A origin=null + GET_VAR 'val intersection: kotlin.Any declared in .test' type=kotlin.Any origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.test.) returnType:kotlin.Any overridden: public abstract fun foo (): kotlin.Any declared in .A @@ -130,7 +130,7 @@ FILE fqName: fileName:/delegationToIntersectionType2.kt RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.Any declared in .test.' CALL 'public abstract fun foo (): kotlin.String declared in .B' type=kotlin.String origin=null $this: TYPE_OP type=.B origin=IMPLICIT_CAST typeOperand=.B - GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.A visibility:private [final]' type=.A origin=null + GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null receiver: GET_VAR ': .test. declared in .test..foo' type=.test. origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt b/compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt new file mode 100644 index 00000000000..156f3beb750 --- /dev/null +++ b/compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt @@ -0,0 +1,40 @@ +// TARGET_BACKEND: JVM_IR +// ISSUE: KT-62544 + +// FILE: Base.java +public interface Base { + String get(); +} + +// FILE: Impl.java +class Impl {} + +// FILE: O.java +public class O extends Impl implements Base { + @Override + public String get() { return "O"; } +} + +// FILE: K.java +public class K extends Impl implements Base { + @Override + public String get() { return "K"; } +} + +// FILE: box.kt +package test + +import O +import K + +fun foo( + b: B, + c: C, + f: (A) -> String +): String { + return f(b) + f(c) +} + +fun box(): String { + return foo(O(), K()) { it.get() } +} diff --git a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.fir.txt b/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.fir.txt deleted file mode 100644 index 65b730f6bf7..00000000000 --- a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.fir.txt +++ /dev/null @@ -1,51 +0,0 @@ -@kotlin.Metadata -public interface A { - // source: 'nonApproxToValidSupertype.kt' -} - -@kotlin.Metadata -public interface B { - // source: 'nonApproxToValidSupertype.kt' -} - -@kotlin.Metadata -public final class G { - // source: 'nonApproxToValidSupertype.kt' - public method (): void - public final method check(@org.jetbrains.annotations.NotNull p0: IFoo): void -} - -@kotlin.Metadata -public interface IFoo { - // source: 'nonApproxToValidSupertype.kt' - public abstract method accept(@org.jetbrains.annotations.NotNull p0: X): void -} - -@kotlin.Metadata -final class NonApproxToValidSupertypeKt$test$1 { - // source: 'nonApproxToValidSupertype.kt' - enclosing method NonApproxToValidSupertypeKt.test()V - public final static field INSTANCE: NonApproxToValidSupertypeKt$test$1 - inner (anonymous) class NonApproxToValidSupertypeKt$test$1 - static method (): void - method (): void - public final method accept(p0: X): void -} - -@kotlin.Metadata -public final class NonApproxToValidSupertypeKt { - // source: 'nonApproxToValidSupertype.kt' - inner (anonymous) class NonApproxToValidSupertypeKt$test$1 - public final static method sel(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object - public final static method test(): void -} - -@kotlin.Metadata -public interface X { - // source: 'nonApproxToValidSupertype.kt' -} - -@kotlin.Metadata -public interface Z { - // source: 'nonApproxToValidSupertype.kt' -} diff --git a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.kt b/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.kt index 276330eb411..6c3d9d5d5b5 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype.kt @@ -1,6 +1,3 @@ -// K1 generates `accept(Object)` and bridge `accept(X)` in the SAM adapter. -// K2 generates `accept(X)` only. It is fine though, because if `check`'s parameter is passed where Z is expected, checkcast is added. - interface X interface Z diff --git a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.fir.txt b/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.fir.txt deleted file mode 100644 index c8e2048af1c..00000000000 --- a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.fir.txt +++ /dev/null @@ -1,62 +0,0 @@ -@kotlin.Metadata -public interface A { - // source: 'nonApproxToValidSupertype2.kt' -} - -@kotlin.Metadata -public interface B { - // source: 'nonApproxToValidSupertype2.kt' -} - -@kotlin.Metadata -public final class G { - // source: 'nonApproxToValidSupertype2.kt' - public method (): void - public final method check(@org.jetbrains.annotations.NotNull p0: IFoo): void -} - -@kotlin.Metadata -public interface IFoo { - // source: 'nonApproxToValidSupertype2.kt' - public abstract method accept(@org.jetbrains.annotations.NotNull p0: U): void -} - -@kotlin.Metadata -final class NonApproxToValidSupertype2Kt$test$1 { - // source: 'nonApproxToValidSupertype2.kt' - enclosing method NonApproxToValidSupertype2Kt.test()V - public final static field INSTANCE: NonApproxToValidSupertype2Kt$test$1 - inner (anonymous) class NonApproxToValidSupertype2Kt$test$1 - static method (): void - method (): void - public synthetic bridge method accept(p0: U): void - public final method accept(p0: X): void -} - -@kotlin.Metadata -public final class NonApproxToValidSupertype2Kt { - // source: 'nonApproxToValidSupertype2.kt' - inner (anonymous) class NonApproxToValidSupertype2Kt$test$1 - public final static method sel(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object - public final static method test(): void -} - -@kotlin.Metadata -public interface U { - // source: 'nonApproxToValidSupertype2.kt' -} - -@kotlin.Metadata -public interface W { - // source: 'nonApproxToValidSupertype2.kt' -} - -@kotlin.Metadata -public interface X { - // source: 'nonApproxToValidSupertype2.kt' -} - -@kotlin.Metadata -public interface Z { - // source: 'nonApproxToValidSupertype2.kt' -} diff --git a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.kt b/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.kt index 372e6ebd0b1..d219d772b12 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/nonApproxToValidSupertype2.kt @@ -1,6 +1,3 @@ -// K1 generates `accept(Object)` and bridge `accept(U)` in the SAM adapter. -// K2 generates `accept(X)` and bridge `accept(U)`. It is fine though, because if `check`'s parameter is passed where Z or W is expected, checkcast is added. - interface X: U, W interface Z: U, W diff --git a/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt b/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt index baef2e63988..8a25b4194d9 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.fir.ir.txt @@ -45,16 +45,16 @@ FILE fqName: fileName:/bangbang.kt if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL - : kotlin.String - arg0: TYPE_OP type=kotlin.String? origin=IMPLICIT_CAST typeOperand=kotlin.String? + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL + : kotlin.Any + arg0: TYPE_OP type=kotlin.Any? origin=IMPLICIT_CAST typeOperand=kotlin.Any? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null WHEN type=kotlin.Unit origin=IF BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String? GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null then: CALL 'public final fun useString (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null - s: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL - : kotlin.String - arg0: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String + s: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Any origin=EXCLEXCL + : kotlin.Any + arg0: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: X of .test4 declared in .test4' type=X of .test4 origin=null diff --git a/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt b/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt index 20fdeee8732..8f34ac79669 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.fir.kt.txt @@ -21,9 +21,10 @@ fun useString(s: String) { fun test4(a: X) { when { - a is String? -> CHECK_NOT_NULL(arg0 = a /*as String? */) /*~> Unit */ + a is String? -> CHECK_NOT_NULL(arg0 = a /*as Any? */) /*~> Unit */ } when { - a is String? -> useString(s = CHECK_NOT_NULL(arg0 = a /*as String */)) + a is String? -> useString(s = CHECK_NOT_NULL(arg0 = a /*as Any */)) } } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt index be00541a0a5..3b0b58c9db6 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt @@ -179,16 +179,16 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:.IFoo [val] - TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Any [val] + TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'fn: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_6: .A declared in .test4' type=.A origin=null - i: GET_VAR 'val tmp_7: .IFoo declared in .test4' type=.IFoo origin=null + i: GET_VAR 'val tmp_7: kotlin.Any declared in .test4' type=kotlin.Any origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_6: .A declared in .test4' type=.A origin=null - i: GET_VAR 'val tmp_7: .IFoo declared in .test4' type=.IFoo origin=null + i: GET_VAR 'val tmp_7: kotlin.Any declared in .test4' type=kotlin.Any origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any @@ -225,14 +225,13 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.Function1 [val] - TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 - GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.Any [val] + GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_10: .A declared in .test6' type=.A origin=null - i: GET_VAR 'val tmp_11: kotlin.Function1 declared in .test6' type=kotlin.Function1 origin=null + i: GET_VAR 'val tmp_11: kotlin.Any declared in .test6' type=kotlin.Any origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_10: .A declared in .test6' type=.A origin=null - i: GET_VAR 'val tmp_11: kotlin.Function1 declared in .test6' type=kotlin.Function1 origin=null + i: GET_VAR 'val tmp_11: kotlin.Any declared in .test6' type=kotlin.Any origin=null other: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt index adf62b0e84d..5b4246ebd33 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -84,7 +84,7 @@ fun test4(fn: Function1) { fn is IFoo -> { // BLOCK { // BLOCK val tmp_6: A = A - val tmp_7: IFoo = fn /*as IFoo */ + val tmp_7: Any = fn /*as Any */ tmp_6.set(i = tmp_7, newValue = tmp_6.get(i = tmp_7).plus(other = 1)) } } @@ -105,7 +105,7 @@ fun test6(a: Any) { a /*as Function1 */ as IFoo /*~> Unit */ { // BLOCK val tmp_10: A = A - val tmp_11: Function1 = a /*as Function1 */ + val tmp_11: Any = a tmp_10.set(i = tmp_11, newValue = tmp_10.get(i = tmp_11).plus(other = 1)) } } diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt index 91bc92d0cba..bb0736fa96d 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.ir.txt @@ -44,7 +44,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + r: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null FUN name:test2 visibility:public modality:FINAL <> (a:.KRunnable) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.KRunnable @@ -53,7 +53,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt TYPE_OP type=kotlin.Function0 origin=CAST typeOperand=kotlin.Function0 GET_VAR 'a: .KRunnable declared in .test2' type=.KRunnable origin=null CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: TYPE_OP type=kotlin.Function0 origin=IMPLICIT_CAST typeOperand=kotlin.Function0 + r: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: .KRunnable declared in .test2' type=.KRunnable origin=null FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 @@ -64,9 +64,9 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + r1: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - r2: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + r2: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0, b:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 @@ -78,7 +78,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public final fun run2 (r1: .KRunnable, r2: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r1: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable + r1: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null r2: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null @@ -106,8 +106,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: TYPE_OP type=.KRunnable origin=IMPLICIT_CAST typeOperand=.KRunnable - GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null + r: GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY @@ -126,7 +125,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function1 declared in .test7' type=kotlin.Function1 origin=null CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null r: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - TYPE_OP type=kotlin.Function0 origin=IMPLICIT_CAST typeOperand=kotlin.Function0 + TYPE_OP type=kotlin.Function origin=IMPLICIT_CAST typeOperand=kotlin.Function GET_VAR 'a: kotlin.Function1 declared in .test7' type=kotlin.Function1 origin=null FUN name:test7a visibility:public modality:FINAL (a:T of .test7a) returnType:kotlin.Unit TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Function1] reified:false @@ -137,7 +136,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: T of .test7a declared in .test7a' type=T of .test7a origin=null CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null r: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - TYPE_OP type=kotlin.Function0 origin=IMPLICIT_CAST typeOperand=kotlin.Function0 + TYPE_OP type=kotlin.Function origin=IMPLICIT_CAST typeOperand=kotlin.Function GET_VAR 'a: T of .test7a declared in .test7a' type=T of .test7a origin=null FUN name:test7b visibility:public modality:FINAL (a:T of .test7b) returnType:kotlin.Unit TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Function1; kotlin.Function0] reified:false diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt index 956c6d898e8..300f379e1b9 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.kt.txt @@ -20,20 +20,20 @@ fun test0(a: T) where T : KRunnable, T : Function0 { fun test1(a: Function0) { when { a is KRunnable -> { // BLOCK - run1(r = a /*as KRunnable */) + run1(r = a /*as Any */) } } } fun test2(a: KRunnable) { a as Function0 /*~> Unit */ - run1(r = a /*as Function0 */) + run1(r = a /*as Any */) } fun test3(a: Function0) { when { a is KRunnable -> { // BLOCK - run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */) + run2(r1 = a /*as Any */, r2 = a /*as Any */) } } } @@ -41,7 +41,7 @@ fun test3(a: Function0) { fun test4(a: Function0, b: Function0) { when { a is KRunnable -> { // BLOCK - run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */) + run2(r1 = a /*as Any */, r2 = b /*-> KRunnable */) } } } @@ -58,7 +58,7 @@ fun test5x(a: Any) { when { a is KRunnable -> { // BLOCK a /*as KRunnable */ as Function0 /*~> Unit */ - run1(r = a /*as KRunnable */) + run1(r = a) } } } @@ -70,12 +70,12 @@ fun test6(a: Any) { fun test7(a: Function1) { a as Function0 /*~> Unit */ - run1(r = a /*as Function0 */ /*-> KRunnable */) + run1(r = a /*as Function */ /*-> KRunnable */) } fun > test7a(a: T) { a as Function0 /*~> Unit */ - run1(r = a /*as Function0 */ /*-> KRunnable */) + run1(r = a /*as Function */ /*-> KRunnable */) } fun test7b(a: T) where T : Function1, T : Function0 { diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.ir.txt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.ir.txt index cbaad963ae4..aca763cf2eb 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.ir.txt @@ -36,11 +36,11 @@ FILE fqName: fileName:/implicitCastToTypeParameter.kt $receiver: VALUE_PARAMETER name: type:.Foo.> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): T of .? declared in ' - WHEN type=T of .? origin=IF + WHEN type=kotlin.Any? origin=IF BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of . GET_VAR ': .Foo.> declared in .' type=.Foo.> origin=null - then: TYPE_OP type=T of . origin=IMPLICIT_CAST typeOperand=T of . + then: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR ': .Foo.> declared in .' type=.Foo.> origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt index 19fce2fad30..cdebb451a5c 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt @@ -12,7 +12,7 @@ interface Foo { val Foo.asT: T? inline get(): T? { return when { - is T -> /*as T */ + is T -> /*as Any */ else -> null } } diff --git a/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.ir.txt b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.ir.txt index 0f3cd0004a1..8be141ad5db 100644 --- a/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.ir.txt @@ -128,8 +128,8 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt CONSTRUCTOR_CALL 'public constructor () declared in .Derived1' type=.Derived1 origin=null VAR name:d2 type:.Derived2 [val] CONSTRUCTOR_CALL 'public constructor () declared in .Derived2' type=.Derived2 origin=null - VAR name:k type:.JFieldOwner [val] - WHEN type=.JFieldOwner origin=IF + VAR name:k type:kotlin.Any [val] + WHEN type=kotlin.Any origin=IF BRANCH if: GET_VAR 'b: kotlin.Boolean declared in .test' type=kotlin.Boolean origin=null then: GET_VAR 'val d1: .Derived1 declared in .test' type=.Derived1 origin=null @@ -137,17 +137,19 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'val d2: .Derived2 declared in .test' type=.Derived2 origin=null SET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:f type:kotlin.Int visibility:public' type=kotlin.Unit origin=EQ - receiver: GET_VAR 'val k: .JFieldOwner declared in .test' type=.JFieldOwner origin=null + receiver: TYPE_OP type=.JFieldOwner origin=IMPLICIT_CAST typeOperand=.JFieldOwner + GET_VAR 'val k: kotlin.Any declared in .test' type=kotlin.Any origin=null value: CONST Int type=kotlin.Int value=42 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:f type:kotlin.Int visibility:public' type=kotlin.Int origin=GET_PROPERTY - receiver: GET_VAR 'val k: .JFieldOwner declared in .test' type=.JFieldOwner origin=null + receiver: TYPE_OP type=.JFieldOwner origin=IMPLICIT_CAST typeOperand=.JFieldOwner + GET_VAR 'val k: kotlin.Any declared in .test' type=kotlin.Any origin=null VAR name:md1 type:.DerivedThroughMid1 [val] CONSTRUCTOR_CALL 'public constructor () declared in .DerivedThroughMid1' type=.DerivedThroughMid1 origin=null VAR name:md2 type:.DerivedThroughMid2 [val] CONSTRUCTOR_CALL 'public constructor () declared in .DerivedThroughMid2' type=.DerivedThroughMid2 origin=null - VAR name:mk type:.Mid [val] - WHEN type=.Mid origin=IF + VAR name:mk type:kotlin.Any [val] + WHEN type=kotlin.Any origin=IF BRANCH if: GET_VAR 'b: kotlin.Boolean declared in .test' type=kotlin.Boolean origin=null then: GET_VAR 'val md1: .DerivedThroughMid1 declared in .test' type=.DerivedThroughMid1 origin=null @@ -155,8 +157,10 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'val md2: .DerivedThroughMid2 declared in .test' type=.DerivedThroughMid2 origin=null SET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:f type:kotlin.Int visibility:public' type=kotlin.Unit origin=EQ - receiver: GET_VAR 'val mk: .Mid declared in .test' type=.Mid origin=null + receiver: TYPE_OP type=.Mid origin=IMPLICIT_CAST typeOperand=.Mid + GET_VAR 'val mk: kotlin.Any declared in .test' type=kotlin.Any origin=null value: CONST Int type=kotlin.Int value=44 TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:f type:kotlin.Int visibility:public' type=kotlin.Int origin=GET_PROPERTY - receiver: GET_VAR 'val mk: .Mid declared in .test' type=.Mid origin=null + receiver: TYPE_OP type=.Mid origin=IMPLICIT_CAST typeOperand=.Mid + GET_VAR 'val mk: kotlin.Any declared in .test' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.kt.txt b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.kt.txt index ff523dae206..b8bd90a7cb8 100644 --- a/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.kt.txt @@ -50,19 +50,19 @@ class DerivedThroughMid2 : Mid, IFoo { fun test(b: Boolean) { val d1: Derived1 = Derived1() val d2: Derived2 = Derived2() - val k: JFieldOwner = when { + val k: Any = when { b -> d1 else -> d2 } - k.#f = 42 - k.#f /*~> Unit */ + k /*as JFieldOwner */.#f = 42 + k /*as JFieldOwner */.#f /*~> Unit */ val md1: DerivedThroughMid1 = DerivedThroughMid1() val md2: DerivedThroughMid2 = DerivedThroughMid2() - val mk: Mid = when { + val mk: Any = when { b -> md1 else -> md2 } - mk.#f = 44 - mk.#f /*~> Unit */ + mk /*as Mid */.#f = 44 + mk /*as Mid */.#f /*~> Unit */ } diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.ir.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.ir.txt index c88d43ada3a..a72218d982d 100644 --- a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.ir.txt @@ -50,8 +50,7 @@ FILE fqName: fileName:/multipleSmartCasts.kt then: CONST Boolean type=kotlin.Boolean value=false then: BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any [val] - TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 - GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null + GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null VAR name:x1 type:kotlin.Int [val] CALL 'public abstract fun component1 (): kotlin.Int declared in .IC1' type=kotlin.Int origin=COMPONENT_N(index=1) $this: TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 @@ -59,5 +58,4 @@ FILE fqName: fileName:/multipleSmartCasts.kt VAR name:x2 type:kotlin.String [val] CALL 'public abstract fun component2 (): kotlin.String declared in .IC2' type=kotlin.String origin=COMPONENT_N(index=2) $this: TYPE_OP type=.IC2 origin=IMPLICIT_CAST typeOperand=.IC2 - TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 - GET_VAR 'val tmp_0: kotlin.Any declared in .test' type=kotlin.Any origin=null + GET_VAR 'val tmp_0: kotlin.Any declared in .test' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt index e7aaf6e653b..22429958368 100644 --- a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt @@ -14,9 +14,10 @@ fun test(x: Any) { x is IC1 -> x /*as IC1 */ is IC2 else -> false } -> { // BLOCK - val tmp_0: Any = x /*as IC1 */ + val tmp_0: Any = x val x1: Int = tmp_0 /*as IC1 */.component1() - val x2: String = tmp_0 /*as IC1 */ /*as IC2 */.component2() + val x2: String = tmp_0 /*as IC2 */.component2() } } } + diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt index 63b0932d477..566a922e1c5 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.ir.txt @@ -8,7 +8,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun runStatic (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + r: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 @@ -20,7 +20,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + r: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test2' type=kotlin.Function0 origin=null FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 @@ -32,9 +32,9 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + r1: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null - r2: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + r2: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test3' type=kotlin.Function0 origin=null FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0, b:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 @@ -47,7 +47,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt then: BLOCK type=kotlin.Unit origin=null CALL 'public open fun run2 (r1: @[FlexibleNullability] java.lang.Runnable?, r2: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r1: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable + r1: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'a: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null r2: TYPE_OP type=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable? GET_VAR 'b: kotlin.Function0 declared in .test4' type=kotlin.Function0 origin=null @@ -77,8 +77,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r: TYPE_OP type=java.lang.Runnable origin=IMPLICIT_CAST typeOperand=java.lang.Runnable - GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null + r: GET_VAR 'a: kotlin.Any declared in .test5x' type=kotlin.Any origin=null FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY @@ -99,7 +98,7 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt CALL 'public open fun run1 (r: @[FlexibleNullability] java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null r: TYPE_OP type=@[FlexibleNullability] java.lang.Runnable? origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.lang.Runnable? - TYPE_OP type=kotlin.Function0 origin=IMPLICIT_CAST typeOperand=kotlin.Function0 + TYPE_OP type=kotlin.Function origin=IMPLICIT_CAST typeOperand=kotlin.Function GET_VAR 'a: kotlin.Function1 declared in .test7' type=kotlin.Function1 origin=null FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt index 425f721ed07..2203f8def80 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt @@ -1,7 +1,7 @@ fun test1(a: Function0) { when { a is Runnable -> { // BLOCK - runStatic(r = a /*as Runnable */) + runStatic(r = a /*as Any */) } } } @@ -9,7 +9,7 @@ fun test1(a: Function0) { fun test2(a: Function0) { when { a is Runnable -> { // BLOCK - J().run1(r = a /*as Runnable */) + J().run1(r = a /*as Any */) } } } @@ -17,7 +17,7 @@ fun test2(a: Function0) { fun test3(a: Function0) { when { a is Runnable -> { // BLOCK - J().run2(r1 = a /*as Runnable */, r2 = a /*as Runnable */) + J().run2(r1 = a /*as Any */, r2 = a /*as Any */) } } } @@ -25,7 +25,7 @@ fun test3(a: Function0) { fun test4(a: Function0, b: Function0) { when { a is Runnable -> { // BLOCK - J().run2(r1 = a /*as Runnable */, r2 = b /*-> @FlexibleNullability Runnable? */) + J().run2(r1 = a /*as Any */, r2 = b /*-> @FlexibleNullability Runnable? */) } } } @@ -42,7 +42,7 @@ fun test5x(a: Any) { when { a is Runnable -> { // BLOCK a /*as Runnable */ as Function0 /*~> Unit */ - J().run1(r = a /*as Runnable */) + J().run1(r = a) } } } @@ -54,7 +54,7 @@ fun test6(a: Any) { fun test7(a: Function1) { a as Function0 /*~> Unit */ - J().run1(r = a /*as Function0 */ /*-> @FlexibleNullability Runnable? */) + J().run1(r = a /*as Function */ /*-> @FlexibleNullability Runnable? */) } fun test8(a: Function0) { diff --git a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.ir.txt b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.ir.txt index 4c5b93d3950..6369726206a 100644 --- a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.ir.txt @@ -49,13 +49,13 @@ FILE fqName: fileName:/smartCastsWithDestructuring.kt then: RETURN type=kotlin.Nothing from='public final fun test (x: .I1): kotlin.Unit declared in ' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.I1 [val] - TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 + TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'x: .I1 declared in .test' type=.I1 origin=null VAR name:c1 type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int declared in ' type=kotlin.Int origin=COMPONENT_N(index=1) - $receiver: TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 + $receiver: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'val tmp_0: .I1 declared in .test' type=.I1 origin=null VAR name:c2 type:kotlin.String [val] CALL 'public final fun component2 (): kotlin.String declared in ' type=kotlin.String origin=COMPONENT_N(index=2) - $receiver: TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 + $receiver: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'val tmp_0: .I1 declared in .test' type=.I1 origin=null diff --git a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt index cc5c3721f59..5782d914ef5 100644 --- a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt @@ -18,7 +18,7 @@ fun test(x: I1) { when { x !is I2 -> return Unit } - val tmp_0: I1 = x /*as I2 */ - val c1: Int = tmp_0 /*as I2 */.component1() - val c2: String = tmp_0 /*as I2 */.component2() + val tmp_0: I1 = x /*as Any */ + val c1: Int = tmp_0 /*as Any */.component1() + val c2: String = tmp_0 /*as Any */.component2() } diff --git a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt index 1a83edb4f10..ee9c0f5f5b5 100644 --- a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.ir.txt @@ -254,7 +254,7 @@ FILE fqName: fileName:/suspendConversionOnArbitraryExpression.kt TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=CAST typeOperand=kotlin.coroutines.SuspendFunction0 GET_VAR 'a: kotlin.Function0 declared in .testSmartCastVsSuspendConversion' type=kotlin.Function0 origin=null CALL 'public final fun useSuspend (sfn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - sfn: TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=IMPLICIT_CAST typeOperand=kotlin.coroutines.SuspendFunction0 + sfn: TYPE_OP type=kotlin.Function origin=IMPLICIT_CAST typeOperand=kotlin.Function GET_VAR 'a: kotlin.Function0 declared in .testSmartCastVsSuspendConversion' type=kotlin.Function0 origin=null FUN name:testSmartCastOnVarVsSuspendConversion visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 @@ -265,7 +265,7 @@ FILE fqName: fileName:/suspendConversionOnArbitraryExpression.kt TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=CAST typeOperand=kotlin.coroutines.SuspendFunction0 GET_VAR 'var b: kotlin.Function0 declared in .testSmartCastOnVarVsSuspendConversion' type=kotlin.Function0 origin=null CALL 'public final fun useSuspend (sfn: kotlin.coroutines.SuspendFunction0): kotlin.Unit declared in ' type=kotlin.Unit origin=null - sfn: TYPE_OP type=kotlin.coroutines.SuspendFunction0 origin=IMPLICIT_CAST typeOperand=kotlin.coroutines.SuspendFunction0 + sfn: TYPE_OP type=kotlin.Function origin=IMPLICIT_CAST typeOperand=kotlin.Function GET_VAR 'var b: kotlin.Function0 declared in .testSmartCastOnVarVsSuspendConversion' type=kotlin.Function0 origin=null FUN name:testIntersectionVsSuspendConversion visibility:public modality:FINAL (x:T of .testIntersectionVsSuspendConversion) returnType:kotlin.Unit TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Function0; kotlin.coroutines.SuspendFunction0] reified:false diff --git a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt index 1624da4a084..2fd04615cdc 100644 --- a/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.fir.kt.txt @@ -175,15 +175,16 @@ fun testSmartCastOnVarWithSuspendConversion(a: Any) { fun testSmartCastVsSuspendConversion(a: Function0) { a as SuspendFunction0 /*~> Unit */ - useSuspend(sfn = a /*as SuspendFunction0 */) + useSuspend(sfn = a /*as Function */) } fun testSmartCastOnVarVsSuspendConversion(a: Function0) { var b: Function0 = a b as SuspendFunction0 /*~> Unit */ - useSuspend(sfn = b /*as SuspendFunction0 */) + useSuspend(sfn = b /*as Function */) } fun testIntersectionVsSuspendConversion(x: T) where T : Function0, T : SuspendFunction0 { useSuspend(sfn = x) } + diff --git a/compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt b/compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt new file mode 100644 index 00000000000..a2f1b7b979b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/Modality.fir.ir.txt @@ -0,0 +1,170 @@ +FILE fqName: fileName:/Modality.kt + CLASS INTERFACE name:Substitutable modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Substitutable.Substitutable> + TYPE_PARAMETER name:T index:0 variance:out superTypes:[.DeclarationDescriptorNonRoot] reified:false + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:ResolutionPart modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ResolutionPart + CONSTRUCTOR visibility:public <> () returnType:.ResolutionPart [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ResolutionPart modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' + FUN name:process visibility:public modality:ABSTRACT <> ($this:.ResolutionPart, $receiver:.KotlinResolutionCandidate) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.ResolutionPart + $receiver: VALUE_PARAMETER name: type:.KotlinResolutionCandidate + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:KotlinResolutionCandidate modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KotlinResolutionCandidate + CONSTRUCTOR visibility:public <> (resolvedCall:.Atom) returnType:.KotlinResolutionCandidate [primary] + VALUE_PARAMETER name:resolvedCall index:0 type:.Atom + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KotlinResolutionCandidate modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:resolvedCall visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.Atom visibility:private [final] + EXPRESSION_BODY + GET_VAR 'resolvedCall: .Atom declared in .KotlinResolutionCandidate.' type=.Atom origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.KotlinResolutionCandidate) returnType:.Atom + correspondingProperty: PROPERTY name:resolvedCall visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.KotlinResolutionCandidate + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .Atom declared in .KotlinResolutionCandidate' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.Atom visibility:private [final]' type=.Atom origin=null + receiver: GET_VAR ': .KotlinResolutionCandidate declared in .KotlinResolutionCandidate.' type=.KotlinResolutionCandidate origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Atom modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Atom + CONSTRUCTOR visibility:public <> (candidateDescriptor:.CallableDescriptor) returnType:.Atom [primary] + VALUE_PARAMETER name:candidateDescriptor index:0 type:.CallableDescriptor + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Atom modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:candidateDescriptor visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:candidateDescriptor type:.CallableDescriptor visibility:private [final] + EXPRESSION_BODY + GET_VAR 'candidateDescriptor: .CallableDescriptor declared in .Atom.' type=.CallableDescriptor origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Atom) returnType:.CallableDescriptor + correspondingProperty: PROPERTY name:candidateDescriptor visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Atom + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .CallableDescriptor declared in .Atom' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:candidateDescriptor type:.CallableDescriptor visibility:private [final]' type=.CallableDescriptor origin=null + receiver: GET_VAR ': .Atom declared in .Atom.' type=.Atom origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:Owner modality:FINAL visibility:public superTypes:[.ResolutionPart] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Owner + CONSTRUCTOR visibility:private <> () returnType:.Owner [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .ResolutionPart' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Owner modality:FINAL visibility:public superTypes:[.ResolutionPart]' + FUN name:process visibility:public modality:OPEN <> ($this:.Owner, $receiver:.KotlinResolutionCandidate) returnType:kotlin.String + overridden: + public abstract fun process (): kotlin.String declared in .ResolutionPart + $this: VALUE_PARAMETER name: type:.Owner + $receiver: VALUE_PARAMETER name: type:.KotlinResolutionCandidate + BLOCK_BODY + VAR name:candidateDescriptor type:.CallableDescriptor [val] + CALL 'public final fun (): .CallableDescriptor declared in .Atom' type=.CallableDescriptor origin=GET_PROPERTY + $this: CALL 'public final fun (): .Atom declared in .KotlinResolutionCandidate' type=.Atom origin=GET_PROPERTY + $this: GET_VAR ': .KotlinResolutionCandidate declared in .Owner.process' type=.KotlinResolutionCandidate origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.MemberDescriptor + GET_VAR 'val candidateDescriptor: .CallableDescriptor declared in .Owner.process' type=.CallableDescriptor origin=null + then: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'public abstract fun getModality (): @[FlexibleNullability] .Modality? declared in .MemberDescriptor' type=@[FlexibleNullability] .Modality? origin=GET_PROPERTY + $this: TYPE_OP type=.MemberDescriptor origin=IMPLICIT_CAST typeOperand=.MemberDescriptor + TYPE_OP type=.DeclarationDescriptor origin=IMPLICIT_CAST typeOperand=.DeclarationDescriptor + GET_VAR 'val candidateDescriptor: .CallableDescriptor declared in .Owner.process' type=.CallableDescriptor origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public open fun process (): kotlin.String declared in .Owner' + CONST String type=kotlin.String value="OK" + RETURN type=kotlin.Nothing from='public open fun process (): kotlin.String declared in .Owner' + CONST String type=kotlin.String value="FAIL" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .ResolutionPart + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in .ResolutionPart + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in .ResolutionPart + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:Final modality:FINAL visibility:public superTypes:[.Modality] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Final + CONSTRUCTOR visibility:private <> () returnType:.Final [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Final modality:FINAL visibility:public superTypes:[.Modality]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Modality + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in .Modality + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in .Modality + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt b/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt new file mode 100644 index 00000000000..daa7f3b849b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt @@ -0,0 +1,71 @@ +interface Substitutable { + +} + +abstract class ResolutionPart { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + abstract fun KotlinResolutionCandidate.process(): String + +} + +class KotlinResolutionCandidate { + constructor(resolvedCall: Atom) /* primary */ { + super/*Any*/() + /* () */ + + } + + val resolvedCall: Atom + field = resolvedCall + get + +} + +class Atom { + constructor(candidateDescriptor: CallableDescriptor) /* primary */ { + super/*Any*/() + /* () */ + + } + + val candidateDescriptor: CallableDescriptor + field = candidateDescriptor + get + +} + +object Owner : ResolutionPart { + private constructor() /* primary */ { + super/*ResolutionPart*/() + /* () */ + + } + + override fun KotlinResolutionCandidate.process(): String { + val candidateDescriptor: CallableDescriptor = .().() + when { + when { + candidateDescriptor is MemberDescriptor -> EQEQ(arg0 = candidateDescriptor /*as DeclarationDescriptor */ /*as MemberDescriptor */.getModality(), arg1 = null).not() + else -> false + } -> { // BLOCK + return "OK" + } + } + return "FAIL" + } + +} + +object Final : Modality { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} diff --git a/compiler/testData/ir/irText/firProblems/Modality.kt b/compiler/testData/ir/irText/firProblems/Modality.kt index bf0d95a17c8..ce386c20b3a 100644 --- a/compiler/testData/ir/irText/firProblems/Modality.kt +++ b/compiler/testData/ir/irText/firProblems/Modality.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // TARGET_BACKEND: JVM // FILE: Modality.java public interface Modality diff --git a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.ir.txt b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.ir.txt index c700c30cb47..ef6450c622e 100644 --- a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.ir.txt @@ -132,8 +132,8 @@ FILE fqName: fileName:/candidateSymbol.kt FUN name:foo visibility:public modality:FINAL <> (candidate:.Candidate) returnType:kotlin.Unit VALUE_PARAMETER name:candidate index:0 type:.Candidate BLOCK_BODY - VAR name:me type:.FirSymbolOwner<*> [val] - CALL 'public final fun (): E of .AbstractFirBasedSymbol declared in .AbstractFirBasedSymbol' type=.FirSymbolOwner<*> origin=GET_PROPERTY + VAR name:me type:kotlin.Any [val] + CALL 'public final fun (): E of .AbstractFirBasedSymbol declared in .AbstractFirBasedSymbol' type=kotlin.Any origin=GET_PROPERTY $this: CALL 'public final fun (): .AbstractFirBasedSymbol<*> declared in .Candidate' type=.AbstractFirBasedSymbol<*> origin=GET_PROPERTY $this: GET_VAR 'candidate: .Candidate declared in .foo' type=.Candidate origin=null WHEN type=kotlin.Unit origin=IF @@ -141,12 +141,12 @@ FILE fqName: fileName:/candidateSymbol.kt if: WHEN type=kotlin.Boolean origin=ANDAND BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.FirCallableMemberDeclaration<*> - GET_VAR 'val me: .FirSymbolOwner<*> declared in .foo' type=.FirSymbolOwner<*> origin=null + GET_VAR 'val me: kotlin.Any declared in .foo' type=kotlin.Any origin=null then: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public abstract fun (): .AbstractFirBasedSymbol.FirCallableMemberDeclaration> declared in .FirCallableMemberDeclaration' type=.AbstractFirBasedSymbol.FirCallableMemberDeclaration<*>> origin=GET_PROPERTY $this: TYPE_OP type=.FirCallableMemberDeclaration<*> origin=IMPLICIT_CAST typeOperand=.FirCallableMemberDeclaration<*> - GET_VAR 'val me: .FirSymbolOwner<*> declared in .foo' type=.FirSymbolOwner<*> origin=null + GET_VAR 'val me: kotlin.Any declared in .foo' type=kotlin.Any origin=null arg1: CONST Null type=kotlin.Nothing? value=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true diff --git a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt index 57605d51e49..0d533aa41f3 100644 --- a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt @@ -41,7 +41,7 @@ interface FirCallableMemberDeclaration> : Fi } fun foo(candidate: Candidate) { - val me: FirSymbolOwner<*> = candidate.().() + val me: Any = candidate.().() when { when { me is FirCallableMemberDeclaration<*> -> EQEQ(arg0 = me /*as FirCallableMemberDeclaration<*> */.(), arg1 = null).not() @@ -50,3 +50,4 @@ fun foo(candidate: Candidate) { } } } + diff --git a/compiler/testData/ir/irText/types/intersectionType2.fir.ir.txt b/compiler/testData/ir/irText/types/intersectionType2.fir.ir.txt deleted file mode 100644 index 249afe360db..00000000000 --- a/compiler/testData/ir/irText/types/intersectionType2.fir.ir.txt +++ /dev/null @@ -1,105 +0,0 @@ -FILE fqName: fileName:/intersectionType2.kt - CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.A> - TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any?] reified:false - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:Foo modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:B modality:OPEN visibility:public superTypes:[.Foo; .A<.B>] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B - CONSTRUCTOR visibility:public <> () returnType:.B [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public superTypes:[.Foo; .A<.B>]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Foo - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in .Foo - public open fun hashCode (): kotlin.Int declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in .Foo - public open fun toString (): kotlin.String declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:C modality:OPEN visibility:public superTypes:[.Foo; .A<.C>] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> () returnType:.C [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:OPEN visibility:public superTypes:[.Foo; .A<.C>]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Foo - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in .Foo - public open fun hashCode (): kotlin.Int declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in .Foo - public open fun toString (): kotlin.String declared in .A - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:run visibility:public modality:FINAL (fn:kotlin.Function0.run>) returnType:T of .run - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.run> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' - CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=T of .run origin=INVOKE - $this: GET_VAR 'fn: kotlin.Function0.run> declared in .run' type=kotlin.Function0.run> origin=VARIABLE_AS_FUNCTION - FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Any declared in ' - CALL 'public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' type=.Foo origin=null - : .Foo - fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:.Foo - BLOCK_BODY - VAR name:mm type:.B [val] - CONSTRUCTOR_CALL 'public constructor () declared in .B' type=.B origin=null - VAR name:nn type:.C [val] - CONSTRUCTOR_CALL 'public constructor () declared in .C' type=.C origin=null - VAR name:c type:.Foo [val] - WHEN type=.Foo origin=IF - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val mm: .B declared in .foo.' type=.B origin=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val nn: .C declared in .foo.' type=.C origin=null - RETURN type=kotlin.Nothing from='local final fun (): .Foo declared in .foo' - GET_VAR 'val c: .Foo declared in .foo.' type=.Foo origin=null diff --git a/compiler/testData/ir/irText/types/intersectionType2.fir.kt.txt b/compiler/testData/ir/irText/types/intersectionType2.fir.kt.txt deleted file mode 100644 index 5c3a035fec9..00000000000 --- a/compiler/testData/ir/irText/types/intersectionType2.fir.kt.txt +++ /dev/null @@ -1,42 +0,0 @@ -interface A { - -} - -interface Foo { - -} - -open class B : Foo, A { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -open class C : Foo, A { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -fun run(fn: Function0): T { - return fn.invoke() -} - -fun foo(): Any { - return run(fn = local fun (): Foo { - val mm: B = B() - val nn: C = C() - val c: Foo = when { - true -> mm - else -> nn - } - return c - } -) -} diff --git a/compiler/testData/ir/irText/types/intersectionType2.kt b/compiler/testData/ir/irText/types/intersectionType2.kt index 62876866d30..dcfd27b0dfe 100644 --- a/compiler/testData/ir/irText/types/intersectionType2.kt +++ b/compiler/testData/ir/irText/types/intersectionType2.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL interface A interface Foo diff --git a/compiler/testData/ir/irText/types/intersectionTypeInSamType.fir.ir.txt b/compiler/testData/ir/irText/types/intersectionTypeInSamType.fir.ir.txt deleted file mode 100644 index b39cf12e5d1..00000000000 --- a/compiler/testData/ir/irText/types/intersectionTypeInSamType.fir.ir.txt +++ /dev/null @@ -1,241 +0,0 @@ -FILE fqName: fileName:/intersectionTypeInSamType.kt - CLASS INTERFACE name:X modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:Z modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[.X; .Z] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .X - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Z - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in .X - public open fun hashCode (): kotlin.Int declared in .Z - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in .X - public open fun toString (): kotlin.String declared in .Z - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[.X; .Z] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .X - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Z - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in .X - public open fun hashCode (): kotlin.Int declared in .Z - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in .X - public open fun toString (): kotlin.String declared in .Z - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo.IFoo> - TYPE_PARAMETER name:T index:0 variance: superTypes:[.X] reified:false - FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo.IFoo>, t:T of .IFoo) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.IFoo.IFoo> - VALUE_PARAMETER name:t index:0 type:T of .IFoo - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:IBar1 modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBar1.IBar1> - TYPE_PARAMETER name:T index:0 variance: superTypes:[.X; .Z] reified:false - FUN name:bar visibility:public modality:ABSTRACT <> ($this:.IBar1.IBar1>, t:T of .IBar1) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.IBar1.IBar1> - VALUE_PARAMETER name:t index:0 type:T of .IBar1 - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:IBar2 modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBar2.IBar2> - TYPE_PARAMETER name:T index:0 variance: superTypes:[.X; .Z] reified:false - FUN name:bar visibility:public modality:ABSTRACT <> ($this:.IBar2.IBar2>, t:T of .IBar2) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.IBar2.IBar2> - VALUE_PARAMETER name:t index:0 type:T of .IBar2 - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:sel visibility:public modality:FINAL (x:T of .sel, y:T of .sel) returnType:T of .sel - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - VALUE_PARAMETER name:x index:0 type:T of .sel - VALUE_PARAMETER name:y index:1 type:T of .sel - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun sel (x: T of .sel, y: T of .sel): T of .sel declared in ' - GET_VAR 'x: T of .sel declared in .sel' type=T of .sel origin=null - CLASS CLASS name:G1 modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.G1.G1> - TYPE_PARAMETER name:T index:0 variance: superTypes:[.X] reified:false - CONSTRUCTOR visibility:public <> () returnType:.G1.G1> [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:G1 modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:checkFoo visibility:public modality:FINAL <> ($this:.G1.G1>, x:.IFoo.G1>) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.G1.G1> - VALUE_PARAMETER name:x index:0 type:.IFoo.G1> - BLOCK_BODY - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:G2 modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.G2.G2> - TYPE_PARAMETER name:T index:0 variance: superTypes:[.X; .Z] reified:false - CONSTRUCTOR visibility:public <> () returnType:.G2.G2> [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:G2 modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:checkFoo visibility:public modality:FINAL <> ($this:.G2.G2>, x:.IFoo.G2>) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.G2.G2> - VALUE_PARAMETER name:x index:0 type:.IFoo.G2> - BLOCK_BODY - FUN name:checkBar1 visibility:public modality:FINAL <> ($this:.G2.G2>, x:.IBar1.G2>) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.G2.G2> - VALUE_PARAMETER name:x index:0 type:.IBar1.G2> - BLOCK_BODY - FUN name:checkBar2 visibility:public modality:FINAL <> ($this:.G2.G2>, x:.IBar2.G2>) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.G2.G2> - VALUE_PARAMETER name:x index:0 type:.IBar2.G2> - BLOCK_BODY - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - VAR name:g type:.G1<*> [val] - CALL 'public final fun sel (x: T of .sel, y: T of .sel): T of .sel declared in ' type=.G1<*> origin=null - : .G1<*> - x: CONSTRUCTOR_CALL 'public constructor () declared in .G1' type=.G1<.A> origin=null - : .A - y: CONSTRUCTOR_CALL 'public constructor () declared in .G1' type=.G1<.B> origin=null - : .B - CALL 'public final fun checkFoo (x: .IFoo.G1>): kotlin.Unit declared in .G1' type=kotlin.Unit origin=null - $this: GET_VAR 'val g: .G1<*> declared in .test1' type=.G1<*> origin=null - x: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.X) returnType:kotlin.Unit - VALUE_PARAMETER name:it index:0 type:.X - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (it: .X): kotlin.Unit declared in .test1' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - VAR name:g type:.G2<*> [val] - CALL 'public final fun sel (x: T of .sel, y: T of .sel): T of .sel declared in ' type=.G2<*> origin=null - : .G2<*> - x: CONSTRUCTOR_CALL 'public constructor () declared in .G2' type=.G2<.A> origin=null - : .A - y: CONSTRUCTOR_CALL 'public constructor () declared in .G2' type=.G2<.B> origin=null - : .B - CALL 'public final fun checkFoo (x: .IFoo.G2>): kotlin.Unit declared in .G2' type=kotlin.Unit origin=null - $this: GET_VAR 'val g: .G2<*> declared in .test2' type=.G2<*> origin=null - x: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.X) returnType:kotlin.Unit - VALUE_PARAMETER name:it index:0 type:.X - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (it: .X): kotlin.Unit declared in .test2' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public final fun checkBar1 (x: .IBar1.G2>): kotlin.Unit declared in .G2' type=kotlin.Unit origin=null - $this: GET_VAR 'val g: .G2<*> declared in .test2' type=.G2<*> origin=null - x: TYPE_OP type=.IBar1 origin=SAM_CONVERSION typeOperand=.IBar1 - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.X) returnType:kotlin.Unit - VALUE_PARAMETER name:it index:0 type:.X - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (it: .X): kotlin.Unit declared in .test2' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public final fun checkBar2 (x: .IBar2.G2>): kotlin.Unit declared in .G2' type=kotlin.Unit origin=null - $this: GET_VAR 'val g: .G2<*> declared in .test2' type=.G2<*> origin=null - x: TYPE_OP type=.IBar2 origin=SAM_CONVERSION typeOperand=.IBar2 - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.X) returnType:kotlin.Unit - VALUE_PARAMETER name:it index:0 type:.X - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (it: .X): kotlin.Unit declared in .test2' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit diff --git a/compiler/testData/ir/irText/types/intersectionTypeInSamType.kt b/compiler/testData/ir/irText/types/intersectionTypeInSamType.kt index c6cc27b0c17..4e8fb6526ee 100644 --- a/compiler/testData/ir/irText/types/intersectionTypeInSamType.kt +++ b/compiler/testData/ir/irText/types/intersectionTypeInSamType.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // SKIP_KT_DUMP // IGNORE_BACKEND_K1: JS_IR // IGNORE_BACKEND_K1: JS_IR_ES6 diff --git a/compiler/testData/ir/irText/types/kt49526.fir.ir.txt b/compiler/testData/ir/irText/types/kt49526.fir.ir.txt deleted file mode 100644 index 5a4874a54ce..00000000000 --- a/compiler/testData/ir/irText/types/kt49526.fir.ir.txt +++ /dev/null @@ -1,15 +0,0 @@ -FILE fqName: fileName:/kt49526.kt - FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Boolean - BLOCK_BODY - VAR name:ref type:kotlin.reflect.KFunction1 [val] - FUNCTION_REFERENCE 'public abstract fun contains (element: E of kotlin.collections.List): kotlin.Boolean declared in kotlin.collections.List' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= - $this: CALL 'public final fun plus (element: T of kotlin.collections.plus): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List origin=PLUS - : kotlin.Comparable - $receiver: CALL 'public final fun listOf (element: T of kotlin.collections.listOf): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List origin=null - : kotlin.Char - element: CONST Char type=kotlin.Char value='a' - element: CONST String type=kotlin.String value="-" - RETURN type=kotlin.Nothing from='public final fun test (): kotlin.Boolean declared in ' - CALL 'public abstract fun invoke (p1: P1 of kotlin.reflect.KFunction1): R of kotlin.reflect.KFunction1 declared in kotlin.reflect.KFunction1' type=kotlin.Boolean origin=INVOKE - $this: GET_VAR 'val ref: kotlin.reflect.KFunction1 declared in .test' type=kotlin.reflect.KFunction1 origin=VARIABLE_AS_FUNCTION - p1: CONST Char type=kotlin.Char value='a' diff --git a/compiler/testData/ir/irText/types/kt49526.kt b/compiler/testData/ir/irText/types/kt49526.kt index 1132dc8657a..8a931f3e31a 100644 --- a/compiler/testData/ir/irText/types/kt49526.kt +++ b/compiler/testData/ir/irText/types/kt49526.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB // SKIP_KT_DUMP // IGNORE_BACKEND: JS_IR diff --git a/compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.ir.txt b/compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.ir.txt deleted file mode 100644 index 59e7e6b9ded..00000000000 --- a/compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.ir.txt +++ /dev/null @@ -1,123 +0,0 @@ -FILE fqName: fileName:/localVariableOfIntersectionType.kt - CLASS INTERFACE name:In modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.In.In> - TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Any?] reified:false - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:Inv modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Inv.Inv> - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - PROPERTY name:t visibility:public modality:ABSTRACT [val] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Inv.Inv>) returnType:T of .Inv - correspondingProperty: PROPERTY name:t visibility:public modality:ABSTRACT [val] - $this: VALUE_PARAMETER name: type:.Inv.Inv> - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:Z modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z - FUN name:create visibility:public modality:ABSTRACT ($this:.Z, x:.In.Z.create>, y:.In.Z.create>) returnType:.Inv.Z.create> - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - $this: VALUE_PARAMETER name: type:.Z - VALUE_PARAMETER name:x index:0 type:.In.Z.create> - VALUE_PARAMETER name:y index:1 type:.In.Z.create> - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:IA modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IA - FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IA) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.IA - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:IB modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IB - FUN name:bar visibility:public modality:ABSTRACT <> ($this:.IB) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.IB - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test visibility:public modality:FINAL <> (a:.In<.IA>, b:.In<.IB>, z:.Z) returnType:kotlin.Unit - VALUE_PARAMETER name:a index:0 type:.In<.IA> - VALUE_PARAMETER name:b index:1 type:.In<.IB> - VALUE_PARAMETER name:z index:2 type:.Z - BLOCK_BODY - CALL 'public abstract fun foo (): kotlin.Unit declared in .IA' type=kotlin.Unit origin=null - $this: CALL 'public abstract fun (): T of .Inv declared in .Inv' type=.IA origin=GET_PROPERTY - $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv origin=null - : .IA - $this: GET_VAR 'z: .Z declared in .test' type=.Z origin=null - x: GET_VAR 'a: .In<.IA> declared in .test' type=.In<.IA> origin=null - y: GET_VAR 'b: .In<.IB> declared in .test' type=.In<.IB> origin=null - CALL 'public abstract fun bar (): kotlin.Unit declared in .IB' type=kotlin.Unit origin=null - $this: TYPE_OP type=.IB origin=IMPLICIT_CAST typeOperand=.IB - CALL 'public abstract fun (): T of .Inv declared in .Inv' type=.IA origin=GET_PROPERTY - $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv origin=null - : .IA - $this: GET_VAR 'z: .Z declared in .test' type=.Z origin=null - x: GET_VAR 'a: .In<.IA> declared in .test' type=.In<.IA> origin=null - y: GET_VAR 'b: .In<.IB> declared in .test' type=.In<.IB> origin=null - VAR name:t type:.IA [val] - CALL 'public abstract fun (): T of .Inv declared in .Inv' type=.IA origin=GET_PROPERTY - $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv origin=null - : .IA - $this: GET_VAR 'z: .Z declared in .test' type=.Z origin=null - x: GET_VAR 'a: .In<.IA> declared in .test' type=.In<.IA> origin=null - y: GET_VAR 'b: .In<.IB> declared in .test' type=.In<.IB> origin=null - CALL 'public abstract fun foo (): kotlin.Unit declared in .IA' type=kotlin.Unit origin=null - $this: GET_VAR 'val t: .IA declared in .test' type=.IA origin=null - CALL 'public abstract fun bar (): kotlin.Unit declared in .IB' type=kotlin.Unit origin=null - $this: TYPE_OP type=.IB origin=IMPLICIT_CAST typeOperand=.IB - GET_VAR 'val t: .IA declared in .test' type=.IA origin=null diff --git a/compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.kt.txt b/compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.kt.txt deleted file mode 100644 index 5adf3761bd6..00000000000 --- a/compiler/testData/ir/irText/types/localVariableOfIntersectionType.fir.kt.txt +++ /dev/null @@ -1,32 +0,0 @@ -interface In { - -} - -interface Inv { - abstract val t: T - abstract get - -} - -interface Z { - abstract fun create(x: In, y: In): Inv - -} - -interface IA { - abstract fun foo() - -} - -interface IB { - abstract fun bar() - -} - -fun test(a: In, b: In, z: Z) { - z.create(x = a, y = b).().foo() - z.create(x = a, y = b).() /*as IB */.bar() - val t: IA = z.create(x = a, y = b).() - t.foo() - t /*as IB */.bar() -} diff --git a/compiler/testData/ir/irText/types/localVariableOfIntersectionType.kt b/compiler/testData/ir/irText/types/localVariableOfIntersectionType.kt index 74ceabd0edb..c81614f73c6 100644 --- a/compiler/testData/ir/irText/types/localVariableOfIntersectionType.kt +++ b/compiler/testData/ir/irText/types/localVariableOfIntersectionType.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL interface In interface Inv { diff --git a/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.ir.txt b/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.ir.txt index 483795eb74a..bda294d30db 100644 --- a/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.ir.txt +++ b/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.ir.txt @@ -104,8 +104,8 @@ FILE fqName: fileName:/receiverOfIntersectionType.kt VALUE_PARAMETER name:a index:0 type:.A VALUE_PARAMETER name:b index:1 type:.B BLOCK_BODY - VAR name:v type:.I [val] - WHEN type=.I origin=IF + VAR name:v type:.K [val] + WHEN type=.K origin=IF BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'a: .A declared in .testIntersection' type=.A origin=null @@ -113,11 +113,12 @@ FILE fqName: fileName:/receiverOfIntersectionType.kt if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'b: .B declared in .testIntersection' type=.B origin=null CALL 'public abstract fun ff (): kotlin.Unit declared in .I' type=kotlin.Unit origin=null - $this: GET_VAR 'val v: .I declared in .testIntersection' type=.I origin=null + $this: TYPE_OP type=.I origin=IMPLICIT_CAST typeOperand=.I + GET_VAR 'val v: .K declared in .testIntersection' type=.K origin=null FUN name:testFlexible1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR name:v type:.I? [val] - WHEN type=.I? origin=IF + VAR name:v type:.K? [val] + WHEN type=.K? origin=IF BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public open fun a (): @[FlexibleNullability] .A? declared in .Java' type=@[FlexibleNullability] .A? origin=null @@ -125,13 +126,13 @@ FILE fqName: fileName:/receiverOfIntersectionType.kt if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public open fun b (): @[FlexibleNullability] .B? declared in .Java' type=@[FlexibleNullability] .B? origin=null CALL 'public abstract fun ff (): kotlin.Unit declared in .I' type=kotlin.Unit origin=null - $this: GET_VAR 'val v: .I? declared in .testFlexible1' type=.I? origin=null + $this: GET_VAR 'val v: .K? declared in .testFlexible1' type=.K? origin=null FUN name:testFlexible2 visibility:public modality:FINAL <> (a:.A, b:.B) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A VALUE_PARAMETER name:b index:1 type:.B BLOCK_BODY - VAR name:v type:.I? [val] - WHEN type=.I? origin=IF + VAR name:v type:.K? [val] + WHEN type=.K? origin=IF BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public open fun id (x: @[FlexibleNullability] T of .Java.id?): @[FlexibleNullability] T of .Java.id? declared in .Java' type=@[FlexibleNullability] .A? origin=null @@ -143,4 +144,4 @@ FILE fqName: fileName:/receiverOfIntersectionType.kt : @[FlexibleNullability] .B? x: GET_VAR 'b: .B declared in .testFlexible2' type=.B origin=null CALL 'public abstract fun ff (): kotlin.Unit declared in .I' type=kotlin.Unit origin=null - $this: GET_VAR 'val v: .I? declared in .testFlexible2' type=.I? origin=null + $this: GET_VAR 'val v: .K? declared in .testFlexible2' type=.K? origin=null diff --git a/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.kt.txt b/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.kt.txt index dd1736682bc..b966cc51c99 100644 --- a/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.kt.txt +++ b/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.kt.txt @@ -36,15 +36,15 @@ class B : I, J { } fun testIntersection(a: A, b: B) { - val v: I = when { + val v: K = when { true -> a else -> b } - v.ff() + v /*as I */.ff() } fun testFlexible1() { - val v: I? = when { + val v: K? = when { true -> a() else -> b() } @@ -52,9 +52,10 @@ fun testFlexible1() { } fun testFlexible2(a: A, b: B) { - val v: I? = when { + val v: K? = when { true -> id<@FlexibleNullability A?>(x = a) else -> id<@FlexibleNullability B?>(x = b) } v.ff() } + 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 3c8a2309823..af4f55979d3 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 @@ -21025,6 +21025,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); } + @Test + @TestMetadata("intersectionWithInvisibleComponent.kt") + public void testIntersectionWithInvisibleComponent() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 51f0357fcca..3c035fcb827 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -21025,6 +21025,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); } + @Test + @TestMetadata("intersectionWithInvisibleComponent.kt") + public void testIntersectionWithInvisibleComponent() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() 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 329222b0980..6bab582de0f 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -17550,6 +17550,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); } + @TestMetadata("intersectionWithInvisibleComponent.kt") + public void testIntersectionWithInvisibleComponent() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionWithInvisibleComponent.kt"); + } + @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { runTest("compiler/testData/codegen/box/inference/kt10822.kt"); diff --git a/libraries/tools/kotlinp/testData/IntersectionTypeInLambdaLiteralAndDelegatedProperty.kt b/libraries/tools/kotlinp/testData/IntersectionTypeInLambdaLiteralAndDelegatedProperty.kt index 8de8b86a344..90a2724f8d8 100644 --- a/libraries/tools/kotlinp/testData/IntersectionTypeInLambdaLiteralAndDelegatedProperty.kt +++ b/libraries/tools/kotlinp/testData/IntersectionTypeInLambdaLiteralAndDelegatedProperty.kt @@ -1,5 +1,3 @@ -// IGNORE K2 - interface A interface B class Inv(e: T)