diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt index bb289a27b6f..735db93dfcd 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt @@ -236,7 +236,8 @@ class ConeRawType(lowerBound: ConeKotlinType, upperBound: ConeKotlinType) : Cone * only via ConeTypeIntersector */ class ConeIntersectionType( - val intersectedTypes: Collection + val intersectedTypes: Collection, + val alternativeType: ConeKotlinType? = null, ) : ConeSimpleKotlinType(), IntersectionTypeConstructorMarker { override val typeArguments: Array get() = emptyArray() @@ -266,7 +267,10 @@ class ConeIntersectionType( if (hashCode != 0) return hashCode return intersectedTypes.hashCode().also { hashCode = it } } +} +fun ConeIntersectionType.withAlternative(alternativeType: ConeKotlinType): ConeIntersectionType { + return ConeIntersectionType(intersectedTypes, alternativeType) } fun ConeIntersectionType.mapTypes(func: (ConeKotlinType) -> ConeKotlinType): ConeIntersectionType { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 992756eef13..3e0c3b4438a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -8,8 +8,11 @@ package org.jetbrains.kotlin.fir.backend import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.classId import org.jetbrains.kotlin.fir.resolve.fullyExpandedType +import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor +import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -20,6 +23,7 @@ import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.types.TypeApproximatorConfiguration import org.jetbrains.kotlin.types.Variance class Fir2IrTypeConverter( @@ -60,6 +64,8 @@ class Fir2IrTypeConverter( private val capturedTypeCache = mutableMapOf() private val errorTypeForCapturedTypeStub by lazy { createErrorType() } + private val typeApproximator = ConeTypeApproximator(session.typeContext) + fun FirTypeRef.toIrType(typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType { capturedTypeCache.clear() return when (this) { @@ -106,9 +112,10 @@ class Fir2IrTypeConverter( typeAnnotations += callGenerator.convertToIrConstructorCall(attributeAnnotation) as? IrConstructorCall ?: continue } val expandedType = fullyExpandedType(session) + val approximatedType = approximateType(expandedType) IrSimpleTypeImpl( - irSymbol, !typeContext.definitelyNotNull && expandedType.isMarkedNullable, - expandedType.typeArguments.map { it.toIrTypeArgument(typeContext) }, + irSymbol, !typeContext.definitelyNotNull && approximatedType.isMarkedNullable, + approximatedType.typeArguments.map { it.toIrTypeArgument(typeContext) }, typeAnnotations ) } @@ -211,6 +218,22 @@ class Fir2IrTypeConverter( private fun getBuiltInClassSymbol(classId: ClassId?): IrClassSymbol? { return classIdToSymbolMap[classId] ?: getArrayClassSymbol(classId) } + + private fun approximateType(type: ConeKotlinType): ConeKotlinType { + if (type is ConeClassLikeType && type.typeArguments.isEmpty()) return type + val substitutor = object : AbstractConeSubstitutor() { + override fun substituteType(type: ConeKotlinType): ConeKotlinType? { + return if (type is ConeIntersectionType) { + type.alternativeType?.let { substituteOrSelf(it) } + } else null + } + } + val typeWithSpecifiedIntersectionTypes = substitutor.substituteOrSelf(type) + return typeApproximator.approximateToSuperType( + typeWithSpecifiedIntersectionTypes, + TypeApproximatorConfiguration.PublicDeclaration + ) ?: type + } } fun FirTypeRef.toIrType( diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 6fb3b107b04..52805e46853 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -16616,6 +16616,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inference/integerLiteralTypeInLamdaReturnType.kt"); } + @Test + @TestMetadata("intersectionTypeInArguments.kt") + public void testIntersectionTypeInArguments() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index 584bdfe76e7..fbcf356f836 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -485,7 +485,11 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo firstCandidate: KotlinTypeMarker, secondCandidate: KotlinTypeMarker ): KotlinTypeMarker { - // TODO - return firstCandidate + require(firstCandidate is ConeKotlinType) + require(secondCandidate is ConeKotlinType) + val intersectionType = firstCandidate.lowerBoundIfFlexible() as? ConeIntersectionType ?: error { + "Expected type is intersection, found $firstCandidate" + } + return intersectionType.withAlternative(secondCandidate) } } diff --git a/compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt b/compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt new file mode 100644 index 00000000000..98a7ada7506 --- /dev/null +++ b/compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt @@ -0,0 +1,25 @@ +// TARGET_BACKEND: JVM +// WITH_STDLIB +// WITH_REFLECT + +import kotlin.reflect.KType +import kotlin.reflect.full.starProjectedType + +fun convertPrimitivesArray(type: KType, args: Sequence): Any? { + val a = when (type.classifier) { + IntArray::class -> args.map { it?.toIntOrNull() } + CharArray::class -> args.map { it?.singleOrNull() } + else -> null + } + val b = a?.toList() + val c = b?.takeUnless { null in it } + val d = c?.toTypedArray() + return d +} + +fun box(): String { + val type = CharArray::class.starProjectedType + val sequence = sequenceOf("O", "K") + val array = convertPrimitivesArray(type, sequence) as Array<*> + return array.joinToString("") { it.toString() } +} diff --git a/compiler/testData/codegen/box/sam/kt11696.kt b/compiler/testData/codegen/box/sam/kt11696.kt index 0619296d355..08e5134b94c 100644 --- a/compiler/testData/codegen/box/sam/kt11696.kt +++ b/compiler/testData/codegen/box/sam/kt11696.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // SAM_CONVERSIONS: CLASS diff --git a/compiler/testData/codegen/box/vararg/kt37715.kt b/compiler/testData/codegen/box/vararg/kt37715.kt index 880a0c327f0..ea128a1f7a8 100644 --- a/compiler/testData/codegen/box/vararg/kt37715.kt +++ b/compiler/testData/codegen/box/vararg/kt37715.kt @@ -3,6 +3,7 @@ // !LANGUAGE: +NewInference // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME +// IR_DUMP import kotlin.collections.toList diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt index 1fc96f0fbe5..b1b5cf221c8 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt @@ -2,13 +2,14 @@ fun test(a: SomeJavaClass) { a.someFunction(hello = local fun (it: String?) { return Unit } - /*-> Hello? */) + /*-> Hello? */) a.plus(hello = local fun (it: String?) { return Unit } - /*-> Hello? */) + /*-> Hello? */) a.get(hello = local fun (it: String?) { return Unit } - /*-> Hello? */) + /*-> Hello? */) } + diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt index 9f430d1e493..9993dde4ead 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt @@ -4,7 +4,7 @@ FILE fqName: fileName:/genericSamProjectedOut.kt BLOCK_BODY CALL 'public open fun someFunction (hello: example.Hello?): kotlin.Unit declared in example.SomeJavaClass' type=kotlin.Unit origin=null $this: GET_VAR 'a: example.SomeJavaClass declared in .test' type=example.SomeJavaClass origin=null - hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? + hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:kotlin.String? @@ -13,7 +13,7 @@ FILE fqName: fileName:/genericSamProjectedOut.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit CALL 'public open fun plus (hello: example.Hello?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=PLUS $this: GET_VAR 'a: example.SomeJavaClass declared in .test' type=example.SomeJavaClass origin=null - hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? + hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:kotlin.String? @@ -22,7 +22,7 @@ FILE fqName: fileName:/genericSamProjectedOut.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit CALL 'public open fun get (hello: example.Hello?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=null $this: GET_VAR 'a: example.SomeJavaClass declared in .test' type=example.SomeJavaClass origin=null - hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? + hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:kotlin.String? diff --git a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt index 1214db912fa..57605d51e49 100644 --- a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.kt.txt @@ -41,7 +41,7 @@ interface FirCallableMemberDeclaration> : Fi } fun foo(candidate: Candidate) { - val me: FirSymbolOwner>>>> = candidate.().() + val me: FirSymbolOwner<*> = candidate.().() when { when { me is FirCallableMemberDeclaration<*> -> EQEQ(arg0 = me /*as FirCallableMemberDeclaration<*> */.(), arg1 = null).not() diff --git a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt index 9ee482fc545..25bcafbb626 100644 --- a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt +++ b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt @@ -130,8 +130,8 @@ FILE fqName: fileName:/candidateSymbol.kt FUN name:foo visibility:public modality:FINAL <> (candidate:.Candidate) returnType:kotlin.Unit VALUE_PARAMETER name:candidate index:0 type:.Candidate BLOCK_BODY - VAR name:me type:.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner>>>> [val] - CALL 'public final fun (): E of .AbstractFirBasedSymbol declared in .AbstractFirBasedSymbol' type=.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner>>>> origin=GET_PROPERTY + VAR name:me type:.FirSymbolOwner<*> [val] + CALL 'public final fun (): E of .AbstractFirBasedSymbol declared in .AbstractFirBasedSymbol' type=.FirSymbolOwner<*> origin=GET_PROPERTY $this: CALL 'public final fun (): .AbstractFirBasedSymbol<*> declared in .Candidate' type=.AbstractFirBasedSymbol<*> origin=GET_PROPERTY $this: GET_VAR 'candidate: .Candidate declared in .foo' type=.Candidate origin=null WHEN type=kotlin.Unit origin=IF @@ -139,12 +139,12 @@ FILE fqName: fileName:/candidateSymbol.kt if: WHEN type=kotlin.Boolean origin=ANDAND BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.FirCallableMemberDeclaration<*> - GET_VAR 'val me: .FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner>>>> [val] declared in .foo' type=.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner>>>> origin=null + GET_VAR 'val me: .FirSymbolOwner<*> [val] declared in .foo' type=.FirSymbolOwner<*> origin=null then: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public abstract fun (): .AbstractFirBasedSymbol.FirCallableMemberDeclaration> declared in .FirCallableMemberDeclaration' type=.AbstractFirBasedSymbol.FirCallableMemberDeclaration<*>> origin=GET_PROPERTY $this: TYPE_OP type=.FirCallableMemberDeclaration<*> origin=IMPLICIT_CAST typeOperand=.FirCallableMemberDeclaration<*> - GET_VAR 'val me: .FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner>>>> [val] declared in .foo' type=.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner.FirSymbolOwner>>>> origin=null + GET_VAR 'val me: .FirSymbolOwner<*> [val] declared in .foo' type=.FirSymbolOwner<*> origin=null arg1: CONST Null type=kotlin.Nothing? value=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true diff --git a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.kt.txt b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.kt.txt index 54c5833bc51..328e9b152aa 100644 --- a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.kt.txt @@ -16,7 +16,7 @@ abstract class AbstractSymbol where E : Recursive, E : Something { } fun foo(list: List) { - val result: List>> = list.filterIsInstance>().map, AbstractSymbol>>(transform = Recursive::symbol) + val result: List> = list.filterIsInstance>().map, AbstractSymbol<*>>(transform = Recursive::symbol) } } diff --git a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt index e8df2d7e507..dbe7a821874 100644 --- a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt +++ b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt @@ -45,14 +45,14 @@ FILE fqName: fileName:/recursiveCapturedTypeInPropertyReference.kt $this: VALUE_PARAMETER name: type:.AbstractSymbol.AbstractSymbol> VALUE_PARAMETER name:list index:0 type:kotlin.collections.List BLOCK_BODY - VAR name:result type:kotlin.collections.List<.AbstractSymbol.Recursive<*>>> [val] - CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.AbstractSymbol.Recursive<*>>> origin=null + VAR name:result type:kotlin.collections.List<.AbstractSymbol<*>> [val] + CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.AbstractSymbol<*>> origin=null : .Recursive<*> - : .AbstractSymbol.Recursive<*>> + : .AbstractSymbol<*> $receiver: CALL 'public final fun filterIsInstance (): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.Recursive<*>> origin=null : .Recursive<*> $receiver: GET_VAR 'list: kotlin.collections.List declared in .AbstractSymbol.foo' type=kotlin.collections.List origin=null - transform: PROPERTY_REFERENCE 'public abstract symbol: .AbstractSymbol.Recursive> [val]' field=null getter='public abstract fun (): .AbstractSymbol.Recursive> declared in .Recursive' setter=null type=kotlin.reflect.KProperty1<.Recursive<*>, .AbstractSymbol<.Recursive<*>>> origin=null + transform: PROPERTY_REFERENCE 'public abstract symbol: .AbstractSymbol.Recursive> [val]' field=null getter='public abstract fun (): .AbstractSymbol.Recursive> declared in .Recursive' setter=null type=kotlin.reflect.KProperty1<.Recursive<*>, .AbstractSymbol> 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 [operator] declared in kotlin.Any diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt index 7d69636b8db..b50277a84c9 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt @@ -1,7 +1,7 @@ @OptIn(markerClass = [ExperimentalTypeInference::class]) fun scopedFlow(@BuilderInference block: @ExtensionFunctionType SuspendFunction2, Unit>): Flow { return flow(block = local suspend fun FlowCollector.() { - val collector: FlowCollector = + val collector: FlowCollector = flowScope(block = local suspend fun CoroutineScope.() { block.invoke(p1 = , p2 = collector) } @@ -12,7 +12,7 @@ fun scopedFlow(@BuilderInference block: @ExtensionFunctionType Suspen fun Flow.onCompletion(action: @ExtensionFunctionType SuspendFunction2, Throwable?, Unit>): Flow { return unsafeFlow(block = local suspend fun FlowCollector.() { - val safeCollector: SafeCollector = SafeCollector(collector = ) + val safeCollector: SafeCollector = SafeCollector(collector = ) safeCollector.invokeSafely(action = action) } ) diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt index e902faac3ee..7ffbffdcde0 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -14,8 +14,8 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.scopedFlow>) returnType:kotlin.Unit [suspend] $receiver: VALUE_PARAMETER name: type:.FlowCollector.scopedFlow> BLOCK_BODY - VAR name:collector type:.FlowCollector [val] - GET_VAR ': .FlowCollector.scopedFlow> declared in .scopedFlow.' type=.FlowCollector origin=null + VAR name:collector type:.FlowCollector [val] + GET_VAR ': .FlowCollector.scopedFlow> declared in .scopedFlow.' type=.FlowCollector origin=null CALL 'public final fun flowScope (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope>): R of .flowScope [suspend] declared in ' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<.CoroutineScope, kotlin.Unit> origin=LAMBDA @@ -25,7 +25,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction2, p2: P2 of kotlin.coroutines.SuspendFunction2): R of kotlin.coroutines.SuspendFunction2 [suspend,operator] declared in kotlin.coroutines.SuspendFunction2' type=kotlin.Unit origin=null $this: GET_VAR 'block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> declared in .scopedFlow' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION p1: GET_VAR ': .CoroutineScope declared in .scopedFlow..' type=.CoroutineScope origin=null - p2: GET_VAR 'val collector: .FlowCollector [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null + p2: GET_VAR 'val collector: .FlowCollector [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> @@ -38,13 +38,13 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.onCompletion>) returnType:kotlin.Unit [suspend] $receiver: VALUE_PARAMETER name: type:.FlowCollector.onCompletion> BLOCK_BODY - VAR name:safeCollector type:.SafeCollector [val] + VAR name:safeCollector type:.SafeCollector [val] CONSTRUCTOR_CALL 'public constructor (collector: .FlowCollector.SafeCollector>) [primary] declared in .SafeCollector' type=.SafeCollector.onCompletion> origin=null : T of .onCompletion collector: GET_VAR ': .FlowCollector.onCompletion> declared in .onCompletion.' type=.FlowCollector.onCompletion> origin=null CALL 'public final fun invokeSafely (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.invokeSafely>, kotlin.Throwable?, kotlin.Unit>): kotlin.Unit [suspend] declared in ' type=kotlin.Unit origin=null : T of .onCompletion - $receiver: GET_VAR 'val safeCollector: .SafeCollector [val] declared in .onCompletion.' type=.SafeCollector.onCompletion> origin=null + $receiver: GET_VAR 'val safeCollector: .SafeCollector [val] declared in .onCompletion.' type=.SafeCollector.onCompletion> origin=null action: GET_VAR 'action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> declared in .onCompletion' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> origin=null FUN name:invokeSafely visibility:public modality:FINAL ($receiver:.FlowCollector.invokeSafely>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.invokeSafely>, kotlin.Throwable?, kotlin.Unit>) returnType:kotlin.Unit [suspend] TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] @@ -90,8 +90,8 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BLOCK_BODY VAR name:channel type:.ChannelCoroutine [val] TYPE_OP type=.ChannelCoroutine origin=CAST typeOperand=.ChannelCoroutine - CALL 'public abstract fun (): .SendChannel.ProducerScope> declared in .ProducerScope' type=.SendChannel origin=GET_PROPERTY - $this: GET_VAR ': .ProducerScope declared in .asFairChannel.' type=.ProducerScope origin=null + CALL 'public abstract fun (): .SendChannel.ProducerScope> declared in .ProducerScope' type=.SendChannel origin=GET_PROPERTY + $this: GET_VAR ': .ProducerScope declared in .asFairChannel.' type=.ProducerScope origin=null CALL 'public final fun collect (action: kotlin.coroutines.SuspendFunction1.collect, kotlin.Unit>): kotlin.Unit [inline,suspend] declared in ' type=kotlin.Unit origin=null : kotlin.Any? $receiver: GET_VAR 'flow: .Flow<*> declared in .asFairChannel' type=.Flow<*> origin=null diff --git a/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt b/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt index 197c0e0b43f..a795811eac8 100644 --- a/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt +++ b/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt @@ -76,7 +76,7 @@ FILE fqName: fileName:/genericFunWithStar.kt VALUE_PARAMETER name:serializers index:0 type:kotlin.Array.I<*>> varargElementType:.I<*> [vararg] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun bar (vararg serializers: .I<*>): .I<*> declared in .Box' - CALL 'public abstract fun foo (tSerializer: .I.Box.foo>): .I<.Box.Box.foo>> declared in .Box' type=.I.Box.IFoo>> origin=null + CALL 'public abstract fun foo (tSerializer: .I.Box.foo>): .I<.Box.Box.foo>> declared in .Box' type=.I.Box<*>> origin=null : .IFoo $this: GET_VAR ': .Box.Box> declared in .Box.bar' type=.Box.Box> origin=null tSerializer: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=.I<*> origin=null diff --git a/compiler/testData/ir/irText/types/intersectionType1_NI.fir.kt.txt b/compiler/testData/ir/irText/types/intersectionType1_NI.fir.kt.txt index 654a8722f94..00b80c7c3ab 100644 --- a/compiler/testData/ir/irText/types/intersectionType1_NI.fir.kt.txt +++ b/compiler/testData/ir/irText/types/intersectionType1_NI.fir.kt.txt @@ -12,7 +12,7 @@ fun select(x: S, y: S): S { } fun foo(a: Array>, b: Array>): Boolean { - return select>>(x = a, y = b).get(index = 0).ofType(y = true) + return select>>(x = a, y = b).get(index = 0).ofType(y = true) } inline fun In.ofType(y: Any?): Boolean { @@ -24,3 +24,4 @@ fun test() { val a2: Array> = arrayOf>(elements = [In()]) foo(a = a1, b = a2) /*~> Unit */ } + diff --git a/compiler/testData/ir/irText/types/intersectionType1_NI.fir.txt b/compiler/testData/ir/irText/types/intersectionType1_NI.fir.txt index 2c8bcfef583..fb21ecf5370 100644 --- a/compiler/testData/ir/irText/types/intersectionType1_NI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType1_NI.fir.txt @@ -34,9 +34,9 @@ FILE fqName: fileName:/intersectionType1_NI.kt RETURN type=kotlin.Nothing from='public final fun foo (a: kotlin.Array<.In.foo>>, b: kotlin.Array<.In>): kotlin.Boolean declared in ' CALL 'public final fun ofType (y: kotlin.Any?): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null : kotlin.Any? - $receiver: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=.In.foo> origin=null - $this: CALL 'public final fun select (x: S of .select, y: S of .select): S of .select declared in ' type=kotlin.Array.In.foo>> origin=null - : kotlin.Array.In.foo>> + $receiver: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=.In origin=null + $this: CALL 'public final fun select (x: S of .select, y: S of .select): S of .select declared in ' type=kotlin.Array.In> origin=null + : kotlin.Array.In> x: GET_VAR 'a: kotlin.Array<.In.foo>> declared in .foo' type=kotlin.Array<.In.foo>> origin=null y: GET_VAR 'b: kotlin.Array<.In> declared in .foo' type=kotlin.Array<.In> origin=null index: CONST Int type=kotlin.Int value=0 diff --git a/compiler/testData/ir/irText/types/intersectionType1_OI.fir.kt.txt b/compiler/testData/ir/irText/types/intersectionType1_OI.fir.kt.txt index 654a8722f94..a0bda919653 100644 --- a/compiler/testData/ir/irText/types/intersectionType1_OI.fir.kt.txt +++ b/compiler/testData/ir/irText/types/intersectionType1_OI.fir.kt.txt @@ -12,7 +12,7 @@ fun select(x: S, y: S): S { } fun foo(a: Array>, b: Array>): Boolean { - return select>>(x = a, y = b).get(index = 0).ofType(y = true) + return select>>(x = a, y = b).get(index = 0).ofType(y = true) } inline fun In.ofType(y: Any?): Boolean { diff --git a/compiler/testData/ir/irText/types/intersectionType1_OI.fir.txt b/compiler/testData/ir/irText/types/intersectionType1_OI.fir.txt index 1f02f6c692b..f168821a086 100644 --- a/compiler/testData/ir/irText/types/intersectionType1_OI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType1_OI.fir.txt @@ -34,9 +34,9 @@ FILE fqName: fileName:/intersectionType1_OI.kt RETURN type=kotlin.Nothing from='public final fun foo (a: kotlin.Array<.In.foo>>, b: kotlin.Array<.In>): kotlin.Boolean declared in ' CALL 'public final fun ofType (y: kotlin.Any?): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null : kotlin.Any? - $receiver: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=.In.foo> origin=null - $this: CALL 'public final fun select (x: S of .select, y: S of .select): S of .select declared in ' type=kotlin.Array.In.foo>> origin=null - : kotlin.Array.In.foo>> + $receiver: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=.In origin=null + $this: CALL 'public final fun select (x: S of .select, y: S of .select): S of .select declared in ' type=kotlin.Array.In> origin=null + : kotlin.Array.In> x: GET_VAR 'a: kotlin.Array<.In.foo>> declared in .foo' type=kotlin.Array<.In.foo>> origin=null y: GET_VAR 'b: kotlin.Array<.In> declared in .foo' type=kotlin.Array<.In> origin=null index: CONST Int type=kotlin.Int value=0 diff --git a/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt b/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt index a3bb2095bca..5207e2b8f0f 100644 --- a/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt @@ -86,7 +86,7 @@ FILE fqName: fileName:/intersectionType2_NI.kt RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Any declared in ' CALL 'public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' type=.Foo origin=null : .Foo - fn: FUN_EXPR type=kotlin.Function0<.Foo> origin=LAMBDA + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:.Foo BLOCK_BODY VAR name:mm type:.B [val] diff --git a/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt b/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt index dea2cc66eb1..241cb76ca7f 100644 --- a/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt @@ -86,7 +86,7 @@ FILE fqName: fileName:/intersectionType2_OI.kt RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Any declared in ' CALL 'public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' type=.Foo origin=null : .Foo - fn: FUN_EXPR type=kotlin.Function0<.Foo> origin=LAMBDA + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:.Foo BLOCK_BODY VAR name:mm type:.B [val] diff --git a/compiler/testData/ir/irText/types/intersectionType3_NI.fir.kt.txt b/compiler/testData/ir/irText/types/intersectionType3_NI.fir.kt.txt deleted file mode 100644 index 92532b9cf0f..00000000000 --- a/compiler/testData/ir/irText/types/intersectionType3_NI.fir.kt.txt +++ /dev/null @@ -1,63 +0,0 @@ -interface In { - -} - -inline fun In.isT(): Boolean { - return is T -} - -inline fun In.asT() { - as T /*~> Unit */ -} - -fun sel(x: S, y: S): S { - return x -} - -interface A { - -} - -interface B { - -} - -interface A1 : A { - -} - -interface A2 : A { - -} - -interface Z1 : A, B { - -} - -interface Z2 : A, B { - -} - -fun testInIs1(x: In, y: In): Boolean { - return sel>(x = x, y = y).isT() -} - -fun testInIs2(x: In, y: In): Boolean { - return sel>(x = x, y = y).isT() -} - -fun testInIs3(x: In, y: In): Boolean { - return sel>(x = x, y = y).isT() -} - -fun testInAs1(x: In, y: In) { - return sel>(x = x, y = y).asT() -} - -fun testInAs2(x: In, y: In) { - return sel>(x = x, y = y).asT() -} - -fun testInAs3(x: In, y: In) { - return sel>(x = x, y = y).asT() -} diff --git a/compiler/testData/ir/irText/types/intersectionType3_NI.fir.txt b/compiler/testData/ir/irText/types/intersectionType3_NI.fir.txt deleted file mode 100644 index acd39dafb6b..00000000000 --- a/compiler/testData/ir/irText/types/intersectionType3_NI.fir.txt +++ /dev/null @@ -1,200 +0,0 @@ -FILE fqName: fileName:/intersectionType3_NI.kt - CLASS INTERFACE name:In modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.In.In> - TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Any?] - 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 - FUN name:isT visibility:public modality:FINAL ($receiver:.In.isT>) returnType:kotlin.Boolean [inline] - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - $receiver: VALUE_PARAMETER name: type:.In.isT> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun isT (): kotlin.Boolean [inline] declared in ' - TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of .isT - GET_VAR ': .In.isT> declared in .isT' type=.In.isT> origin=null - FUN name:asT visibility:public modality:FINAL ($receiver:.In.asT>) returnType:kotlin.Unit [inline] - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - $receiver: VALUE_PARAMETER name: type:.In.asT> - BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - TYPE_OP type=T of .asT origin=CAST typeOperand=T of .asT - GET_VAR ': .In.asT> declared in .asT' type=.In.asT> origin=null - FUN name:sel visibility:public modality:FINAL (x:S of .sel, y:S of .sel) returnType:S of .sel - TYPE_PARAMETER name:S index:0 variance: superTypes:[kotlin.Any?] - VALUE_PARAMETER name:x index:0 type:S of .sel - VALUE_PARAMETER name:y index:1 type:S of .sel - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' - GET_VAR 'x: S of .sel declared in .sel' type=S of .sel 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 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:A1 modality:ABSTRACT visibility:public superTypes:[.A] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A1 - 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 - CLASS INTERFACE name:A2 modality:ABSTRACT visibility:public superTypes:[.A] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A2 - 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 - CLASS INTERFACE name:Z1 modality:ABSTRACT visibility:public superTypes:[.A; .B] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z1 - 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 INTERFACE name:Z2 modality:ABSTRACT visibility:public superTypes:[.A; .B] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z2 - 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:testInIs1 visibility:public modality:FINAL <> (x:.In<.A>, y:.In<.B>) returnType:kotlin.Boolean - VALUE_PARAMETER name:x index:0 type:.In<.A> - VALUE_PARAMETER name:y index:1 type:.In<.B> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInIs1 (x: .In<.A>, y: .In<.B>): kotlin.Boolean declared in ' - CALL 'public final fun isT (): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null - : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A> origin=null - : .In<.A> - x: GET_VAR 'x: .In<.A> declared in .testInIs1' type=.In<.A> origin=null - y: GET_VAR 'y: .In<.B> declared in .testInIs1' type=.In<.B> origin=null - FUN name:testInIs2 visibility:public modality:FINAL <> (x:.In<.Z1>, y:.In<.Z2>) returnType:kotlin.Boolean - VALUE_PARAMETER name:x index:0 type:.In<.Z1> - VALUE_PARAMETER name:y index:1 type:.In<.Z2> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInIs2 (x: .In<.Z1>, y: .In<.Z2>): kotlin.Boolean declared in ' - CALL 'public final fun isT (): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null - : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.Z1> origin=null - : .In<.Z1> - x: GET_VAR 'x: .In<.Z1> declared in .testInIs2' type=.In<.Z1> origin=null - y: GET_VAR 'y: .In<.Z2> declared in .testInIs2' type=.In<.Z2> origin=null - FUN name:testInIs3 visibility:public modality:FINAL <> (x:.In<.A1>, y:.In<.A2>) returnType:kotlin.Boolean - VALUE_PARAMETER name:x index:0 type:.In<.A1> - VALUE_PARAMETER name:y index:1 type:.In<.A2> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInIs3 (x: .In<.A1>, y: .In<.A2>): kotlin.Boolean declared in ' - CALL 'public final fun isT (): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null - : .A - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A1> origin=null - : .In<.A1> - x: GET_VAR 'x: .In<.A1> declared in .testInIs3' type=.In<.A1> origin=null - y: GET_VAR 'y: .In<.A2> declared in .testInIs3' type=.In<.A2> origin=null - FUN name:testInAs1 visibility:public modality:FINAL <> (x:.In<.A>, y:.In<.B>) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:.In<.A> - VALUE_PARAMETER name:y index:1 type:.In<.B> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInAs1 (x: .In<.A>, y: .In<.B>): kotlin.Unit declared in ' - CALL 'public final fun asT (): kotlin.Unit [inline] declared in ' type=kotlin.Unit origin=null - : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A> origin=null - : .In<.A> - x: GET_VAR 'x: .In<.A> declared in .testInAs1' type=.In<.A> origin=null - y: GET_VAR 'y: .In<.B> declared in .testInAs1' type=.In<.B> origin=null - FUN name:testInAs2 visibility:public modality:FINAL <> (x:.In<.Z1>, y:.In<.Z2>) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:.In<.Z1> - VALUE_PARAMETER name:y index:1 type:.In<.Z2> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInAs2 (x: .In<.Z1>, y: .In<.Z2>): kotlin.Unit declared in ' - CALL 'public final fun asT (): kotlin.Unit [inline] declared in ' type=kotlin.Unit origin=null - : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.Z1> origin=null - : .In<.Z1> - x: GET_VAR 'x: .In<.Z1> declared in .testInAs2' type=.In<.Z1> origin=null - y: GET_VAR 'y: .In<.Z2> declared in .testInAs2' type=.In<.Z2> origin=null - FUN name:testInAs3 visibility:public modality:FINAL <> (x:.In<.A1>, y:.In<.A2>) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:.In<.A1> - VALUE_PARAMETER name:y index:1 type:.In<.A2> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testInAs3 (x: .In<.A1>, y: .In<.A2>): kotlin.Unit declared in ' - CALL 'public final fun asT (): kotlin.Unit [inline] declared in ' type=kotlin.Unit origin=null - : .A - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A1> origin=null - : .In<.A1> - x: GET_VAR 'x: .In<.A1> declared in .testInAs3' type=.In<.A1> origin=null - y: GET_VAR 'y: .In<.A2> declared in .testInAs3' type=.In<.A2> origin=null diff --git a/compiler/testData/ir/irText/types/intersectionType3_NI.kt b/compiler/testData/ir/irText/types/intersectionType3_NI.kt index b4ae0fc410f..e410a6aab27 100644 --- a/compiler/testData/ir/irText/types/intersectionType3_NI.kt +++ b/compiler/testData/ir/irText/types/intersectionType3_NI.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +NewInference interface In diff --git a/compiler/testData/ir/irText/types/intersectionType3_OI.fir.kt.txt b/compiler/testData/ir/irText/types/intersectionType3_OI.fir.kt.txt index 92532b9cf0f..cdf61cbb830 100644 --- a/compiler/testData/ir/irText/types/intersectionType3_OI.fir.kt.txt +++ b/compiler/testData/ir/irText/types/intersectionType3_OI.fir.kt.txt @@ -39,25 +39,26 @@ interface Z2 : A, B { } fun testInIs1(x: In, y: In): Boolean { - return sel>(x = x, y = y).isT() + return sel>(x = x, y = y).isT() } fun testInIs2(x: In, y: In): Boolean { - return sel>(x = x, y = y).isT() + return sel>(x = x, y = y).isT() } fun testInIs3(x: In, y: In): Boolean { - return sel>(x = x, y = y).isT() + return sel>(x = x, y = y).isT() } fun testInAs1(x: In, y: In) { - return sel>(x = x, y = y).asT() + return sel>(x = x, y = y).asT() } fun testInAs2(x: In, y: In) { - return sel>(x = x, y = y).asT() + return sel>(x = x, y = y).asT() } fun testInAs3(x: In, y: In) { - return sel>(x = x, y = y).asT() + return sel>(x = x, y = y).asT() } + diff --git a/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt b/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt index de72928776f..361246b3813 100644 --- a/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt @@ -139,8 +139,8 @@ FILE fqName: fileName:/intersectionType3_OI.kt RETURN type=kotlin.Nothing from='public final fun testInIs1 (x: .In<.A>, y: .In<.B>): kotlin.Boolean declared in ' CALL 'public final fun isT (): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A> origin=null - : .In<.A> + $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In origin=null + : .In x: GET_VAR 'x: .In<.A> declared in .testInIs1' type=.In<.A> origin=null y: GET_VAR 'y: .In<.B> declared in .testInIs1' type=.In<.B> origin=null FUN name:testInIs2 visibility:public modality:FINAL <> (x:.In<.Z1>, y:.In<.Z2>) returnType:kotlin.Boolean @@ -150,8 +150,8 @@ FILE fqName: fileName:/intersectionType3_OI.kt RETURN type=kotlin.Nothing from='public final fun testInIs2 (x: .In<.Z1>, y: .In<.Z2>): kotlin.Boolean declared in ' CALL 'public final fun isT (): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.Z1> origin=null - : .In<.Z1> + $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In origin=null + : .In x: GET_VAR 'x: .In<.Z1> declared in .testInIs2' type=.In<.Z1> origin=null y: GET_VAR 'y: .In<.Z2> declared in .testInIs2' type=.In<.Z2> origin=null FUN name:testInIs3 visibility:public modality:FINAL <> (x:.In<.A1>, y:.In<.A2>) returnType:kotlin.Boolean @@ -161,8 +161,8 @@ FILE fqName: fileName:/intersectionType3_OI.kt RETURN type=kotlin.Nothing from='public final fun testInIs3 (x: .In<.A1>, y: .In<.A2>): kotlin.Boolean declared in ' CALL 'public final fun isT (): kotlin.Boolean [inline] declared in ' type=kotlin.Boolean origin=null : .A - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A1> origin=null - : .In<.A1> + $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In origin=null + : .In x: GET_VAR 'x: .In<.A1> declared in .testInIs3' type=.In<.A1> origin=null y: GET_VAR 'y: .In<.A2> declared in .testInIs3' type=.In<.A2> origin=null FUN name:testInAs1 visibility:public modality:FINAL <> (x:.In<.A>, y:.In<.B>) returnType:kotlin.Unit @@ -172,8 +172,8 @@ FILE fqName: fileName:/intersectionType3_OI.kt RETURN type=kotlin.Nothing from='public final fun testInAs1 (x: .In<.A>, y: .In<.B>): kotlin.Unit declared in ' CALL 'public final fun asT (): kotlin.Unit [inline] declared in ' type=kotlin.Unit origin=null : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A> origin=null - : .In<.A> + $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In origin=null + : .In x: GET_VAR 'x: .In<.A> declared in .testInAs1' type=.In<.A> origin=null y: GET_VAR 'y: .In<.B> declared in .testInAs1' type=.In<.B> origin=null FUN name:testInAs2 visibility:public modality:FINAL <> (x:.In<.Z1>, y:.In<.Z2>) returnType:kotlin.Unit @@ -183,8 +183,8 @@ FILE fqName: fileName:/intersectionType3_OI.kt RETURN type=kotlin.Nothing from='public final fun testInAs2 (x: .In<.Z1>, y: .In<.Z2>): kotlin.Unit declared in ' CALL 'public final fun asT (): kotlin.Unit [inline] declared in ' type=kotlin.Unit origin=null : kotlin.Any - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.Z1> origin=null - : .In<.Z1> + $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In origin=null + : .In x: GET_VAR 'x: .In<.Z1> declared in .testInAs2' type=.In<.Z1> origin=null y: GET_VAR 'y: .In<.Z2> declared in .testInAs2' type=.In<.Z2> origin=null FUN name:testInAs3 visibility:public modality:FINAL <> (x:.In<.A1>, y:.In<.A2>) returnType:kotlin.Unit @@ -194,7 +194,7 @@ FILE fqName: fileName:/intersectionType3_OI.kt RETURN type=kotlin.Nothing from='public final fun testInAs3 (x: .In<.A1>, y: .In<.A2>): kotlin.Unit declared in ' CALL 'public final fun asT (): kotlin.Unit [inline] declared in ' type=kotlin.Unit origin=null : .A - $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In<.A1> origin=null - : .In<.A1> + $receiver: CALL 'public final fun sel (x: S of .sel, y: S of .sel): S of .sel declared in ' type=.In origin=null + : .In x: GET_VAR 'x: .In<.A1> declared in .testInAs3' type=.In<.A1> origin=null y: GET_VAR 'y: .In<.A2> declared in .testInAs3' type=.In<.A2> origin=null diff --git a/compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.fir.txt b/compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.fir.txt index b49be83326c..b9616c7f93b 100644 --- a/compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.fir.txt +++ b/compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.fir.txt @@ -96,7 +96,7 @@ FILE fqName: fileName:/localVariableOfIntersectionType_NI.kt BLOCK_BODY CALL 'public abstract fun foo (): kotlin.Unit declared in .IA' type=kotlin.Unit origin=null $this: CALL 'public abstract fun (): T of .Inv declared in .Inv' type=.IA origin=GET_PROPERTY - $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv<.IA> origin=null + $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv origin=null : .IA $this: GET_VAR 'z: .Z declared in .test' type=.Z origin=null x: GET_VAR 'a: .In<.IA> declared in .test' type=.In<.IA> origin=null @@ -104,14 +104,14 @@ FILE fqName: fileName:/localVariableOfIntersectionType_NI.kt CALL 'public abstract fun bar (): kotlin.Unit declared in .IB' type=kotlin.Unit origin=null $this: TYPE_OP type=.IB origin=IMPLICIT_CAST typeOperand=.IB CALL 'public abstract fun (): T of .Inv declared in .Inv' type=.IA origin=GET_PROPERTY - $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv<.IA> origin=null + $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv origin=null : .IA $this: GET_VAR 'z: .Z declared in .test' type=.Z origin=null x: GET_VAR 'a: .In<.IA> declared in .test' type=.In<.IA> origin=null y: GET_VAR 'b: .In<.IB> declared in .test' type=.In<.IB> origin=null VAR name:t type:.IA [val] CALL 'public abstract fun (): T of .Inv declared in .Inv' type=.IA origin=GET_PROPERTY - $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv<.IA> origin=null + $this: CALL 'public abstract fun create (x: .In.Z.create>, y: .In.Z.create>): .Inv.Z.create> declared in .Z' type=.Inv origin=null : .IA $this: GET_VAR 'z: .Z declared in .test' type=.Z origin=null x: GET_VAR 'a: .In<.IA> declared in .test' type=.In<.IA> origin=null 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 ccd5737fa04..bd9fd13d05d 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 @@ -16616,6 +16616,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inference/integerLiteralTypeInLamdaReturnType.kt"); } + @Test + @TestMetadata("intersectionTypeInArguments.kt") + public void testIntersectionTypeInArguments() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 896f8b3168d..6208023c355 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 @@ -16616,6 +16616,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inference/integerLiteralTypeInLamdaReturnType.kt"); } + @Test + @TestMetadata("intersectionTypeInArguments.kt") + public void testIntersectionTypeInArguments() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); + } + @Test @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 72b51693871..acb9990ac99 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13790,6 +13790,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inference/integerLiteralTypeInLamdaReturnType.kt"); } + @TestMetadata("intersectionTypeInArguments.kt") + public void testIntersectionTypeInArguments() throws Exception { + runTest("compiler/testData/codegen/box/inference/intersectionTypeInArguments.kt"); + } + @TestMetadata("kt10822.kt") public void testKt10822() throws Exception { runTest("compiler/testData/codegen/box/inference/kt10822.kt");