diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index d9d84dc2204..a983c1c547c 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -309,13 +309,13 @@ class Fir2IrImplicitCastInserter( return implicitCastOrExpression(original, castType.toIrType(conversionTypeContext)) } - internal fun implicitCastOrExpression(original: IrExpression, castType: IrType): IrExpression { - val originalNotNull = original.type.makeNotNull() - if (originalNotNull == castType.makeNotNull()) return original - return implicitCast(original, castType) - } - companion object { + internal fun implicitCastOrExpression(original: IrExpression, castType: IrType): IrExpression { + val originalNotNull = original.type.makeNotNull() + if (originalNotNull == castType.makeNotNull()) return original + return implicitCast(original, castType) + } + private fun implicitCast(original: IrExpression, castType: IrType): IrExpression { val typeOperator = if (original.type is IrDynamicType) { IrTypeOperator.IMPLICIT_DYNAMIC_CAST diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 73b97a1cae9..bf879cd0bef 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -991,7 +991,7 @@ class Fir2IrVisitor( if (notNullType == originalType) { irGetLhsValue() } else { - implicitCastInserter.implicitCastOrExpression( + Fir2IrImplicitCastInserter.implicitCastOrExpression( irGetLhsValue(), firLhsVariable.returnTypeRef.resolvedTypeFromPrototype(notNullType).toIrType() ) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt index d114d7ea74f..762eb03e8b9 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt @@ -13,23 +13,18 @@ import org.jetbrains.kotlin.fir.declarations.utils.modality import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.delegatedWrapperData +import org.jetbrains.kotlin.fir.resolve.scope import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.* -import org.jetbrains.kotlin.fir.types.ConeClassLikeType -import org.jetbrains.kotlin.fir.types.coneType -import org.jetbrains.kotlin.fir.types.lowerBoundIfFlexible -import org.jetbrains.kotlin.fir.types.toSymbol +import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl -import org.jetbrains.kotlin.ir.types.classifierOrNull +import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl -import org.jetbrains.kotlin.ir.types.isNothing -import org.jetbrains.kotlin.ir.types.isNullable -import org.jetbrains.kotlin.ir.types.isUnit import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.JvmNames.JVM_DEFAULT_CLASS_ID @@ -94,8 +89,6 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I // Generate delegated members for [subClass]. The synthetic field [irField] has the super interface type. fun generate(irField: IrField, firField: FirField, firSubClass: FirClass, subClass: IrClass) { - val subClassLookupTag = firSubClass.symbol.toLookupTag() - val subClassScope = firSubClass.unsubstitutedScope( session, scopeSession, @@ -103,17 +96,12 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I memberRequiredPhase = null, ) - val delegateToType = firField.initializer!!.typeRef.coneType.fullyExpandedType(session).lowerBoundIfFlexible() - val delegateToClass = delegateToType.toSymbol(session).boundClass() + val delegateToScope = firField.initializer!!.typeRef.coneType + .fullyExpandedType(session) + .lowerBoundIfFlexible() + .scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing, null) ?: return - val delegateToScope = delegateToClass.unsubstitutedScope( - session, - scopeSession, - withForcedTypeCalculator = false, - memberRequiredPhase = null, - ) - - val delegateToLookupTag = (delegateToType as? ConeClassLikeType)?.lookupTag + val subClassLookupTag = firSubClass.symbol.toLookupTag() subClassScope.processAllFunctions { functionSymbol -> val unwrapped = @@ -126,9 +114,13 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I delegateToScope::processOverriddenFunctions ) ?: return@processAllFunctions + val delegateToLookupTag = delegateToSymbol.dispatchReceiverClassLookupTagOrNull() + ?: return@processAllFunctions + val irSubFunction = generateDelegatedFunction( subClass, firSubClass, functionSymbol.fir ) + bodiesInfo += DeclarationBodyInfo(irSubFunction, irField, delegateToSymbol, delegateToLookupTag) declarationStorage.cacheDelegationFunction(functionSymbol.fir, irSubFunction) subClass.addMember(irSubFunction) @@ -152,6 +144,9 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I delegateToScope::processOverriddenProperties ) ?: return@processAllProperties + val delegateToLookupTag = delegateToSymbol.dispatchReceiverClassLookupTagOrNull() + ?: return@processAllProperties + val irSubProperty = generateDelegatedProperty( subClass, firSubClass, propertySymbol.fir ) @@ -184,7 +179,7 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I } } } - return result + return result?.unwrapSubstitutionOverrides() } fun bindDelegatedMembersOverriddenSymbols(irClass: IrClass) { @@ -247,22 +242,31 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I val irCall = IrCallImpl( startOffset, endOffset, - delegateFunction.returnType, + superFunction.returnType, superFunction.symbol, superFunction.typeParameters.size, superFunction.valueParameters.size ).apply { - dispatchReceiver = - IrGetFieldImpl( + val getField = IrGetFieldImpl( + startOffset, endOffset, + irField.symbol, + irField.type, + IrGetValueImpl( startOffset, endOffset, - irField.symbol, - irField.type, - IrGetValueImpl( - startOffset, endOffset, - delegateFunction.dispatchReceiverParameter?.type!!, - delegateFunction.dispatchReceiverParameter?.symbol!! - ) + delegateFunction.dispatchReceiverParameter?.type!!, + delegateFunction.dispatchReceiverParameter?.symbol!! ) + ) + + // When the delegation expression has an intersection type, it is not guaranteed that the field will have the same type as the + // dispatch receiver of the target method. Therefore, we need to check if a cast must be inserted. + val superFunctionParent = superFunction.parent as? IrClass + dispatchReceiver = if (superFunctionParent == null || irField.type.isSubtypeOfClass(superFunctionParent.symbol)) { + getField + } else { + Fir2IrImplicitCastInserter.implicitCastOrExpression(getField, superFunction.dispatchReceiverParameter!!.type) + } + extensionReceiver = delegateFunction.extensionReceiverParameter?.let { extensionReceiver -> IrGetValueImpl(startOffset, endOffset, extensionReceiver.type, extensionReceiver.symbol) @@ -282,6 +286,7 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I } } val resultType = delegateFunction.returnType + val irCastOrCall = if (callTypeCanBeNullable && !resultType.isNullable()) Fir2IrImplicitCastInserter.implicitNotNullCast(irCall) else irCall @@ -366,4 +371,3 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I } } } - 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 23b89b10728..e0d0bddfcd2 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 @@ -15731,6 +15731,18 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + + @Test + @TestMetadata("delegationToIntersectionType2.kt") + public void testDelegationToIntersectionType2() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt"); + } + @Test @TestMetadata("delegationToMap.kt") public void testDelegationToMap() throws Exception { @@ -15827,6 +15839,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/delegation/simple.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() 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 6f4aab872dc..0f3905edd25 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 @@ -15731,6 +15731,18 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + + @Test + @TestMetadata("delegationToIntersectionType2.kt") + public void testDelegationToIntersectionType2() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt"); + } + @Test @TestMetadata("delegationToMap.kt") public void testDelegationToMap() throws Exception { @@ -15827,6 +15839,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/delegation/simple.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType.fir.ir.txt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.fir.ir.txt new file mode 100644 index 00000000000..a8646b805f1 --- /dev/null +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.fir.ir.txt @@ -0,0 +1,149 @@ +FILE fqName: fileName:/delegationToIntersectionType.kt + FUN name:select visibility:public modality:FINAL (a:T of .select, b:T of .select) returnType:T of .select + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + VALUE_PARAMETER name:a index:0 type:T of .select + VALUE_PARAMETER name:b index:1 type:T of .select + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun select (a: T of .select, b: T of .select): T of .select declared in ' + GET_VAR 'a: T of .select declared in .select' type=T of .select origin=null + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $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 [operator] 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:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.B) returnType:kotlin.String + $this: VALUE_PARAMETER 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 [operator] 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:C modality:FINAL visibility:public superTypes:[.A; .B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.A; .B]' + FUN name:foo visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .C' + CONST String type=kotlin.String value="OK" + 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 [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B + $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 [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B + $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 [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:D modality:FINAL visibility:public superTypes:[.A; .B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.D + CONSTRUCTOR visibility:public <> () returnType:.D [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[.A; .B]' + FUN name:foo visibility:public modality:OPEN <> ($this:.D) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:.D + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .D' + 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 [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B + $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 [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B + $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 [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> (c:.C, d:.D) returnType:kotlin.String + 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 + 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 ' + CALL 'public open fun foo (): kotlin.String declared in .test.' type=kotlin.String origin=null + $this: BLOCK type=.test. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test. + CONSTRUCTOR visibility:public <> () returnType:.test. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.B]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.test.) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:.test. + BLOCK_BODY + 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 + receiver: GET_VAR ': .test. declared in .test..foo' type=.test. origin=null + FIELD DELEGATE name:$$delegate_0 type:.A visibility:private [final] + EXPRESSION_BODY + GET_VAR 'val intersection: .A [val] declared in .test' type=.A 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 [fake_override,operator] declared in .B + $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 [fake_override] declared in .B + $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 [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun test (c: .C, d: .D): kotlin.String declared in ' type=kotlin.String origin=null + c: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + d: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .D' type=.D origin=null diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType.ir.txt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.ir.txt new file mode 100644 index 00000000000..bd7996204ef --- /dev/null +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.ir.txt @@ -0,0 +1,149 @@ +FILE fqName: fileName:/delegationToIntersectionType.kt + FUN name:select visibility:public modality:FINAL (a:T of .select, b:T of .select) returnType:T of .select + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + VALUE_PARAMETER name:a index:0 type:T of .select + VALUE_PARAMETER name:b index:1 type:T of .select + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun select (a: T of .select, b: T of .select): T of .select declared in ' + GET_VAR 'a: T of .select declared in .select' type=T of .select origin=null + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $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 [operator] 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:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.B) returnType:kotlin.String + $this: VALUE_PARAMETER 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 [operator] 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:C modality:FINAL visibility:public superTypes:[.A; .B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.A; .B]' + FUN name:foo visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .C' + CONST String type=kotlin.String value="OK" + 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 [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B + $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 [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B + $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 [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:D modality:FINAL visibility:public superTypes:[.A; .B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.D + CONSTRUCTOR visibility:public <> () returnType:.D [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[.A; .B]' + FUN name:foo visibility:public modality:OPEN <> ($this:.D) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:.D + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .D' + 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 [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B + $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 [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B + $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 [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> (c:.C, d:.D) returnType:kotlin.String + VALUE_PARAMETER name:c index:0 type:.C + VALUE_PARAMETER name:d index:1 type:.D + BLOCK_BODY + 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 ' + CALL 'public open fun foo (): kotlin.String declared in .test.' type=kotlin.String origin=null + $this: BLOCK type=.test. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test. + CONSTRUCTOR visibility:public <> () returnType:.test. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.B]' + FIELD DELEGATE name:$$delegate_0 type:kotlin.Any visibility:private [final] + EXPRESSION_BODY + GET_VAR 'val intersection: kotlin.Any [val] 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 + $this: VALUE_PARAMETER name: type:.test. + BLOCK_BODY + 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: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: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B + $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 [fake_override] declared in .B + $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 [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun test (c: .C, d: .D): kotlin.String declared in ' type=kotlin.String origin=null + c: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + d: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .D' type=.D origin=null diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt new file mode 100644 index 00000000000..f2b58c35c75 --- /dev/null +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt @@ -0,0 +1,21 @@ +// DUMP_IR + +fun select(a: T, b: T) : T = a + +interface A +interface B { + fun foo(): String +} +class C : A, B { + override fun foo() = "OK" +} +class D : A, B { + override fun foo() = "FAIL" +} + +fun test(c: C, d: D): String { + val intersection = select(c, d) + return object: B by intersection {}.foo() +} + +fun box() = test(C(), D()) \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.fir.ir.txt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.fir.ir.txt new file mode 100644 index 00000000000..b23aa6280ef --- /dev/null +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.fir.ir.txt @@ -0,0 +1,154 @@ +FILE fqName: fileName:/delegationToIntersectionType2.kt + FUN name:select visibility:public modality:FINAL (a:T of .select, b:T of .select) returnType:T of .select + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + VALUE_PARAMETER name:a index:0 type:T of .select + VALUE_PARAMETER name:b index:1 type:T of .select + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun select (a: T of .select, b: T of .select): T of .select declared in ' + GET_VAR 'a: T of .select declared in .select' type=T of .select origin=null + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.A) returnType:kotlin.Any + $this: VALUE_PARAMETER 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 [operator] 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:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.B) returnType:kotlin.String + $this: VALUE_PARAMETER 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 [operator] 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:C modality:FINAL visibility:public superTypes:[.A; .B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.A; .B]' + FUN name:foo visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.Any declared in .A + public abstract fun foo (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .C' + CONST String type=kotlin.String value="OK" + 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 [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B + $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 [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B + $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 [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:D modality:FINAL visibility:public superTypes:[.A; .B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.D + CONSTRUCTOR visibility:public <> () returnType:.D [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[.A; .B]' + FUN name:foo visibility:public modality:OPEN <> ($this:.D) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.Any declared in .A + public abstract fun foo (): kotlin.String declared in .B + $this: VALUE_PARAMETER name: type:.D + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .D' + 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 [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B + $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 [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B + $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 [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test visibility:public modality:FINAL <> (c:.C, d:.D) returnType:kotlin.String + 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 + 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 ' + CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null + $this: CALL 'public open fun foo (): kotlin.Any declared in .test.' type=kotlin.Any origin=null + $this: BLOCK type=.test. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test. + CONSTRUCTOR visibility:public <> () returnType:.test. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.A]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.test.) returnType:kotlin.Any + overridden: + public abstract fun foo (): kotlin.Any declared in .A + $this: VALUE_PARAMETER name: type:.test. + BLOCK_BODY + 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 + receiver: GET_VAR ': .test. declared in .test..foo' type=.test. origin=null + FIELD DELEGATE name:$$delegate_0 type:.A visibility:private [final] + EXPRESSION_BODY + GET_VAR 'val intersection: .A [val] declared in .test' type=.A 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 [fake_override,operator] 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 [fake_override] 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 [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun test (c: .C, d: .D): kotlin.String declared in ' type=kotlin.String origin=null + c: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + d: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .D' type=.D origin=null diff --git a/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt new file mode 100644 index 00000000000..287c3039b72 --- /dev/null +++ b/compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_K1: ANY +// DUMP_IR +// K1_STATUS: java.lang.AssertionError: There is still an unbound symbol after generation of IR module
+ +fun select(a: T, b: T) : T = a + +interface A { + fun foo(): Any +} +interface B { + fun foo(): String +} +class C : A, B { + override fun foo() = "OK" +} +class D : A, B { + override fun foo() = "FAIL" +} + +fun test(c: C, d: D): String { + val intersection = select(c, d) + return object: A by intersection {}.foo().toString() +} + +fun box() = test(C(), D()) \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegation/smartCastedDelegation.kt b/compiler/testData/codegen/box/delegation/smartCastedDelegation.kt new file mode 100644 index 00000000000..1b86fb45c35 --- /dev/null +++ b/compiler/testData/codegen/box/delegation/smartCastedDelegation.kt @@ -0,0 +1,12 @@ +interface DosFileAttributeView { + fun bar(): String +} + +fun foo(view: V): DosFileAttributeView { + view as DosFileAttributeView + return object : DosFileAttributeView by view {} +} + +fun box() = foo(object : DosFileAttributeView { + override fun bar() = "OK" +}).bar() \ No newline at end of file diff --git a/compiler/testData/codegen/box/functions/delegatedPropertyWithMultipleOverriddens_generics.fir.ir.txt b/compiler/testData/codegen/box/functions/delegatedPropertyWithMultipleOverriddens_generics.fir.ir.txt index 4c1e9b05641..f1b180d9137 100644 --- a/compiler/testData/codegen/box/functions/delegatedPropertyWithMultipleOverriddens_generics.fir.ir.txt +++ b/compiler/testData/codegen/box/functions/delegatedPropertyWithMultipleOverriddens_generics.fir.ir.txt @@ -203,7 +203,7 @@ FILE fqName: fileName:/delegatedPropertyWithMultipleOverriddens_generics.k $this: VALUE_PARAMETER name: type:.MC BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .MC' - CALL 'public open fun foo (): E6 of .MyArrayList declared in .MyArrayList' type=kotlin.String origin=null + CALL 'public open fun foo (): E6 of .MyArrayList declared in .MyArrayList' type=E6 of .MyArrayList origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.MyArrayList visibility:private [final]' type=.MyArrayList origin=null receiver: GET_VAR ': .MC declared in .MC.foo' type=.MC origin=null PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val] @@ -216,7 +216,7 @@ FILE fqName: fileName:/delegatedPropertyWithMultipleOverriddens_generics.k $this: VALUE_PARAMETER name: type:.MC BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .MC' - CALL 'public open fun (): E6 of .MyArrayList declared in .MyArrayList' type=kotlin.String origin=null + CALL 'public open fun (): E6 of .MyArrayList declared in .MyArrayList' type=E6 of .MyArrayList origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.MyArrayList visibility:private [final]' type=.MyArrayList origin=null receiver: GET_VAR ': .MC declared in .MC.' type=.MC origin=null FIELD DELEGATE name:$$delegate_0 type:.MyArrayList visibility:private [final] diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt index 53cc4a1111e..0dfde2e45c2 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt @@ -72,7 +72,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt $receiver: VALUE_PARAMETER name: type:C of .Test1. BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test1, C of .Test1.>? declared in .Test1' - CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test1, C of .Test1.>? origin=null + CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.IBase, C of .IBase.>? origin=null : C of .Test1. $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null @@ -89,7 +89,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.Test1.> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): D of .Test1.? declared in .Test1' - CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test1.? origin=null + CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .IBase.? origin=null : D of .Test1. $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null @@ -158,7 +158,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt $receiver: VALUE_PARAMETER name: type:C of .Test2. BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test2.>? declared in .Test2' - CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test2.>? origin=null + CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.IBase, C of .IBase.>? origin=null : C of .Test2. $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null @@ -175,7 +175,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.Test2.> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): D of .Test2.? declared in .Test2' - CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test2.? origin=null + CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .IBase.? origin=null : D of .Test2. $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.ir.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.ir.txt index 7c9d8be8d3f..e8ff66461fd 100644 --- a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.ir.txt @@ -138,7 +138,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestJFoo' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in .JFoo' type=kotlin.String origin=null + CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in .JFoo' type=@[EnhancedNullability] kotlin.String origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.JFoo visibility:private [final]' type=.JFoo origin=null receiver: GET_VAR ': .TestJFoo declared in .TestJFoo.foo' type=.TestJFoo origin=null FIELD DELEGATE name:$$delegate_0 type:.JFoo visibility:private [final] @@ -170,7 +170,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK1' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String [fake_override] declared in .K1' type=kotlin.String origin=null + CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in .JFoo' type=@[EnhancedNullability] kotlin.String origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.K1 visibility:private [final]' type=.K1 origin=null receiver: GET_VAR ': .TestK1 declared in .TestK1.foo' type=.TestK1 origin=null FIELD DELEGATE name:$$delegate_0 type:.K1 visibility:private [final] @@ -264,7 +264,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK4' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .K4' type=kotlin.String origin=null + CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .K4' type=@[FlexibleNullability] kotlin.String? origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.K4 visibility:private [final]' type=.K4 origin=null receiver: GET_VAR ': .TestK4 declared in .TestK4.foo' type=.TestK4 origin=null FIELD DELEGATE name:$$delegate_0 type:.K4 visibility:private [final] diff --git a/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt b/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt index 895a53a5e0a..777c3d258f3 100644 --- a/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/kt45934.fir.ir.txt @@ -13,7 +13,7 @@ FILE fqName: fileName:/kt45934.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): @[FlexibleNullability] kotlin.collections.MutableList<@[FlexibleNullability] C of .C.foo?>? declared in .C' - CALL 'public open fun foo (): @[FlexibleNullability] kotlin.collections.MutableList<@[FlexibleNullability] kotlin.String?>? declared in .J' type=@[FlexibleNullability] kotlin.collections.MutableList<@[FlexibleNullability] C of .C.foo?>? origin=null + CALL 'public open fun foo (): @[FlexibleNullability] kotlin.collections.MutableList<@[FlexibleNullability] kotlin.String?>? declared in .J' type=@[FlexibleNullability] kotlin.collections.MutableList<@[FlexibleNullability] kotlin.String?>? origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.J visibility:private [final]' type=.J origin=null receiver: GET_VAR ': .C declared in .C.foo' type=.C origin=null FIELD DELEGATE name:$$delegate_0 type:.J visibility:private [final] diff --git a/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt b/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt index cbce6dbadf1..05f1be1ca08 100644 --- a/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/kt35550.fir.ir.txt @@ -42,7 +42,7 @@ FILE fqName: fileName:/kt35550.kt $receiver: VALUE_PARAMETER name: type:T of .A. BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): T of .A. declared in .A' - CALL 'public open fun (): T of .I. declared in .I' type=T of .A. origin=null + CALL 'public open fun (): T of .I. declared in .I' type=T of .I. origin=null : T of .A. $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.I visibility:private [final]' type=.I origin=null receiver: GET_VAR ': .A declared in .A.' type=.A origin=null diff --git a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.ir.txt b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.ir.txt index b66f4a52eb5..d80198ce773 100644 --- a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.ir.txt @@ -14,7 +14,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt VALUE_PARAMETER name:element index:0 type:@[FlexibleNullability] kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun add (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean declared in .Impl' - CALL 'public abstract fun add (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun add (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.add' type=.Impl origin=null element: GET_VAR 'element: @[FlexibleNullability] kotlin.String? declared in .Impl.add' type=@[FlexibleNullability] kotlin.String? origin=null @@ -26,7 +26,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun addAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean declared in .Impl' - CALL 'public abstract fun addAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun addAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.addAll' type=.Impl origin=null elements: GET_VAR 'elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> declared in .Impl.addAll' type=kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> origin=null @@ -36,7 +36,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt public abstract fun clear (): kotlin.Unit [fake_override] declared in .Foo.B $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY - CALL 'public abstract fun clear (): kotlin.Unit [fake_override] declared in .Foo.B' type=kotlin.Unit origin=null + CALL 'public abstract fun clear (): kotlin.Unit declared in kotlin.collections.MutableSet' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.clear' type=.Impl origin=null FUN DELEGATED_MEMBER name:iterator visibility:public modality:OPEN <> ($this:.Impl) returnType:kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> [operator] @@ -46,7 +46,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun iterator (): kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> [operator] declared in .Impl' - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> [fake_override,operator] declared in .Foo.B' type=kotlin.collections.MutableIterator<@[FlexibleNullability] kotlin.String?> origin=null + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [operator] declared in kotlin.collections.MutableSet' type=kotlin.collections.MutableIterator origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.iterator' type=.Impl origin=null FUN DELEGATED_MEMBER name:remove visibility:public modality:OPEN <> ($this:.Impl, element:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Boolean @@ -57,7 +57,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt VALUE_PARAMETER name:element index:0 type:@[FlexibleNullability] kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun remove (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean declared in .Impl' - CALL 'public abstract fun remove (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun remove (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.remove' type=.Impl origin=null element: GET_VAR 'element: @[FlexibleNullability] kotlin.String? declared in .Impl.remove' type=@[FlexibleNullability] kotlin.String? origin=null @@ -69,7 +69,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun removeAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean declared in .Impl' - CALL 'public abstract fun removeAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun removeAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.removeAll' type=.Impl origin=null elements: GET_VAR 'elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> declared in .Impl.removeAll' type=kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> origin=null @@ -81,7 +81,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun retainAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean declared in .Impl' - CALL 'public abstract fun retainAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun retainAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.retainAll' type=.Impl origin=null elements: GET_VAR 'elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> declared in .Impl.retainAll' type=kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> origin=null @@ -93,7 +93,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt VALUE_PARAMETER name:element index:0 type:@[FlexibleNullability] kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun contains (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [operator] declared in .Impl' - CALL 'public abstract fun contains (element: @[FlexibleNullability] kotlin.String?): kotlin.Boolean [fake_override,operator] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun contains (element: E of kotlin.collections.Set): kotlin.Boolean [operator] declared in kotlin.collections.Set' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.contains' type=.Impl origin=null element: GET_VAR 'element: @[FlexibleNullability] kotlin.String? declared in .Impl.contains' type=@[FlexibleNullability] kotlin.String? origin=null @@ -105,7 +105,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun containsAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean declared in .Impl' - CALL 'public abstract fun containsAll (elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?>): kotlin.Boolean [fake_override] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.Set' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.containsAll' type=.Impl origin=null elements: GET_VAR 'elements: kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> declared in .Impl.containsAll' type=kotlin.collections.Collection<@[FlexibleNullability] kotlin.String?> origin=null @@ -116,7 +116,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun isEmpty (): kotlin.Boolean declared in .Impl' - CALL 'public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in .Foo.B' type=kotlin.Boolean origin=null + CALL 'public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Set' type=kotlin.Boolean origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.isEmpty' type=.Impl origin=null PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val] @@ -131,7 +131,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Impl' - CALL 'public abstract fun (): kotlin.Int [fake_override] declared in .Foo.B' type=kotlin.Int origin=null + CALL 'public abstract fun (): kotlin.Int declared in kotlin.collections.Set' type=kotlin.Int origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final]' type=.Foo.B origin=null receiver: GET_VAR ': .Impl declared in .Impl.' type=.Impl origin=null FIELD DELEGATE name:$$delegate_0 type:.Foo.B visibility:private [final] diff --git a/compiler/testData/ir/irText/firProblems/FakeOverrideInAnonymousWithDelegation.fir.ir.txt b/compiler/testData/ir/irText/firProblems/FakeOverrideInAnonymousWithDelegation.fir.ir.txt index de874f3197a..a1733879360 100644 --- a/compiler/testData/ir/irText/firProblems/FakeOverrideInAnonymousWithDelegation.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/FakeOverrideInAnonymousWithDelegation.fir.ir.txt @@ -64,7 +64,7 @@ FILE fqName: fileName:/FakeOverrideInAnonymousWithDelegation.kt $this: VALUE_PARAMETER name: type:.Wrapper.bar. BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .Wrapper.bar.' - CALL 'public open fun (): kotlin.String [fake_override] declared in .Wrapper.dummy.' type=kotlin.String origin=null + CALL 'public open fun (): kotlin.String declared in .Bar' type=kotlin.String origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Wrapper.dummy. visibility:private [final]' type=.Wrapper.dummy. origin=null receiver: GET_VAR ': .Wrapper.bar. declared in .Wrapper.bar..' type=.Wrapper.bar. origin=null FIELD DELEGATE name:$$delegate_0 type:.Wrapper.dummy. visibility:private [final] diff --git a/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt b/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt index 5df16423e43..62649d849cb 100644 --- a/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt @@ -37,7 +37,7 @@ FILE fqName: fileName:/kt43342.kt VALUE_PARAMETER name:key index:0 type:K of .ControlFlowInfo BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun get (key: K of .ControlFlowInfo): V of .ControlFlowInfo? [operator] declared in .ControlFlowInfo' - CALL 'public abstract fun get (key: K of kotlin.collections.Map): V of kotlin.collections.Map? [operator] declared in kotlin.collections.Map' type=V of .ControlFlowInfo? origin=null + CALL 'public abstract fun get (key: K of kotlin.collections.Map): V of kotlin.collections.Map? [operator] declared in kotlin.collections.Map' type=V of kotlin.collections.Map? origin=null $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.get' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null key: GET_VAR 'key: K of .ControlFlowInfo declared in .ControlFlowInfo.get' type=K of .ControlFlowInfo origin=null @@ -60,7 +60,7 @@ FILE fqName: fileName:/kt43342.kt $this: VALUE_PARAMETER name: type:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Set.ControlFlowInfo, V of .ControlFlowInfo>> declared in .ControlFlowInfo' - CALL 'public abstract fun (): kotlin.collections.Set> declared in kotlin.collections.Map' type=kotlin.collections.Set.ControlFlowInfo, V of .ControlFlowInfo>> origin=null + CALL 'public abstract fun (): kotlin.collections.Set> declared in kotlin.collections.Map' type=kotlin.collections.Set> origin=null $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY DELEGATED_MEMBER name:keys visibility:public modality:OPEN [val] @@ -73,7 +73,7 @@ FILE fqName: fileName:/kt43342.kt $this: VALUE_PARAMETER name: type:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Set.ControlFlowInfo> declared in .ControlFlowInfo' - CALL 'public abstract fun (): kotlin.collections.Set declared in kotlin.collections.Map' type=kotlin.collections.Set.ControlFlowInfo> origin=null + CALL 'public abstract fun (): kotlin.collections.Set declared in kotlin.collections.Map' type=kotlin.collections.Set origin=null $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val] @@ -99,7 +99,7 @@ FILE fqName: fileName:/kt43342.kt $this: VALUE_PARAMETER name: type:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Collection.ControlFlowInfo> declared in .ControlFlowInfo' - CALL 'public abstract fun (): kotlin.collections.Collection declared in kotlin.collections.Map' type=kotlin.collections.Collection.ControlFlowInfo> origin=null + CALL 'public abstract fun (): kotlin.collections.Collection declared in kotlin.collections.Map' type=kotlin.collections.Collection origin=null $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY name:map visibility:public modality:FINAL [val] diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt index 766ba2617f6..5c31a85557f 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt @@ -62,7 +62,7 @@ FILE fqName: fileName:/nullCheckOnInterfaceDelegation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .Delegated' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .Derived' type=kotlin.String origin=null + CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .Derived' type=@[FlexibleNullability] kotlin.String? origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Derived visibility:private [final]' type=.Derived origin=null receiver: GET_VAR ': .Delegated declared in .Delegated.foo' type=.Delegated origin=null FIELD DELEGATE name:$$delegate_0 type:.Derived visibility:private [final] diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index cb7aa7ac743..6c5d42f587d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -15401,6 +15401,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + + @Test + @TestMetadata("delegationToIntersectionType2.kt") + public void testDelegationToIntersectionType2() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt"); + } + @Test @TestMetadata("delegationToMap.kt") public void testDelegationToMap() throws Exception { @@ -15485,6 +15497,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/delegation/simple.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 3e5a201e0e8..1be8b019447 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 @@ -15731,6 +15731,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + + @Test + @TestMetadata("delegationToIntersectionType2.kt") + public void testDelegationToIntersectionType2() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt"); + } + @Test @TestMetadata("delegationToMap.kt") public void testDelegationToMap() throws Exception { @@ -15827,6 +15839,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/delegation/simple.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() 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 01d5340dbc5..ca19944723d 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 @@ -15731,6 +15731,18 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + + @Test + @TestMetadata("delegationToIntersectionType2.kt") + public void testDelegationToIntersectionType2() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt"); + } + @Test @TestMetadata("delegationToMap.kt") public void testDelegationToMap() throws Exception { @@ -15827,6 +15839,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/delegation/simple.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() 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 42bfd63c614..1dabb85dd6a 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12630,6 +12630,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + + @TestMetadata("delegationToIntersectionType2.kt") + public void testDelegationToIntersectionType2() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType2.kt"); + } + @TestMetadata("delegationToMap.kt") public void testDelegationToMap() throws Exception { runTest("compiler/testData/codegen/box/delegation/delegationToMap.kt"); @@ -12695,6 +12705,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/delegation/simple.kt"); } + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 3c0cd37d4f0..a9a0fb0fc23 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -11779,6 +11779,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -11815,6 +11821,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index cf38fa55a3e..505a1a55938 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -11875,6 +11875,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -11911,6 +11917,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 689762b6e1a..43d7b4deaec 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -11875,6 +11875,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -11911,6 +11917,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index c2d1ecbf247..2d57bf2f461 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -11875,6 +11875,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -11911,6 +11917,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java index b9a87cd5e3f..0da4c69fe13 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java @@ -13164,6 +13164,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -13200,6 +13206,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java index f4e16b51a82..e777f560faa 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java @@ -13464,6 +13464,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -13500,6 +13506,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index b6111c7350f..7df8f4cc991 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -13014,6 +13014,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -13050,6 +13056,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java index cd53aab1a0c..a4d6c89e6c0 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java @@ -13314,6 +13314,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @Test + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @Test @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { @@ -13350,6 +13356,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @Test + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @Test @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java index cca3d6f86b0..40a31c0e99d 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java @@ -10515,6 +10515,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/delegation/delegationDifferentModule.kt"); } + @TestMetadata("delegationToIntersectionType.kt") + public void testDelegationToIntersectionType() throws Exception { + runTest("compiler/testData/codegen/box/delegation/delegationToIntersectionType.kt"); + } + @TestMetadata("delegationWithPrivateConstructor.kt") public void testDelegationWithPrivateConstructor() throws Exception { runTest("compiler/testData/codegen/box/delegation/delegationWithPrivateConstructor.kt"); @@ -10545,6 +10550,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @TestMetadata("smartCastedDelegation.kt") + public void testSmartCastedDelegation() throws Exception { + runTest("compiler/testData/codegen/box/delegation/smartCastedDelegation.kt"); + } + @TestMetadata("viaTypeAlias.kt") public void testViaTypeAlias() throws Exception { runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");