diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/typeAliasWithNotNullBound.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/typeAliasWithNotNullBound.txt index 3fe6693c865..eda23012129 100644 --- a/compiler/fir/analysis-tests/testData/resolve/callResolution/typeAliasWithNotNullBound.txt +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/typeAliasWithNotNullBound.txt @@ -7,7 +7,7 @@ FILE: typeAliasWithNotNullBound.kt } public final typealias MyAlias = R|Inv| public final fun foo(p: R|MyAlias|): R|kotlin/Unit| { - R|/bar|(R|/p|).R|kotlin/CharSequence.length| + R|/bar|(R|/p|).R|kotlin/CharSequence.length| } public final fun bar(x: R|Inv|): R|T| { ^bar R|kotlin/TODO|() diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.txt b/compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.txt index 05d95fd8eca..ddfbabd241b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.txt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/capturedTypeForJavaTypeParameter.txt @@ -4,5 +4,5 @@ FILE: main.kt public final fun foo(b: R|B|): R|kotlin/Unit| { } public final fun main(b: R|B<*>|): R|kotlin/Unit| { - R|/foo|(R|/b|) + R|/foo|!|>(R|/b|) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/integerLiteralAsComparable.txt b/compiler/fir/analysis-tests/testData/resolve/inference/integerLiteralAsComparable.txt index a8fe3f11fc7..587d6730f8d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/integerLiteralAsComparable.txt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/integerLiteralAsComparable.txt @@ -7,5 +7,5 @@ FILE: main.kt } public final fun main(): R|kotlin/Unit| { R|/K.K|(Int(0)) - R|/JavaClass.JavaClass|!|>(Int(0)) + R|/JavaClass.JavaClass|!|>(Int(0)) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.txt b/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.txt index 0d23752d58e..5c359a9798e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.txt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.txt @@ -15,19 +15,19 @@ FILE: receiverWithCapturedType.kt ^updateD R|/d| } public final fun test_1_1(resolvedCall: R|ResolvedCall|): R|kotlin/Unit| { - R|/resolvedCall|.R|/getParameterForArgument|() + R|/resolvedCall|.R|/getParameterForArgument|() } public final fun test_1_2(resolvedCall: R|ResolvedCall|): R|kotlin/Unit| { - R|/resolvedCall|.R|/getParameterForArgument|() + R|/resolvedCall|.R|/getParameterForArgument|() } public final fun test_1_3(resolvedCall: R|ResolvedCall|): R|kotlin/Unit| { R|/resolvedCall|.R|/getParameterForArgument|() } public final fun test_2_1(resolvedCall: R|ResolvedCall|, d: R|CallableDescriptor|): R|kotlin/Unit| { - lval x: R|CallableDescriptor| = R|/resolvedCall|.#(R|/d|) + lval x: R|CallableDescriptor| = R|/resolvedCall|.#(R|/d|) } public final fun test_2_2(resolvedCall: R|ResolvedCall|, d: R|CallableDescriptor|): R|kotlin/Unit| { - lval x: R|CallableDescriptor| = R|/resolvedCall|.R|/updateD|(R|/d|) + lval x: R|CallableDescriptor| = R|/resolvedCall|.R|/updateD|(R|/d|) } public final fun test_2_3(resolvedCall: R|ResolvedCall|, d: R|CallableDescriptor|): R|kotlin/Unit| { lval x: R|CallableDescriptor| = R|/resolvedCall|.R|/updateD|(R|/d|) diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/simpleCapturedTypes.txt b/compiler/fir/analysis-tests/testData/resolve/inference/simpleCapturedTypes.txt index a9cb7e76358..ebf330ef599 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/simpleCapturedTypes.txt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/simpleCapturedTypes.txt @@ -19,10 +19,10 @@ FILE: simpleCapturedTypes.kt ^ this@R|/idP| } private final fun getSetterInfos(kc: R|KC|): R|kotlin/Unit| { - R|/id|(R|/kc|).R|FakeOverride|.R|/Ann.foo|() - R|/kc|.R|/idR|().R|FakeOverride|.R|/Ann.foo|() - R|/kc|.R|/idP|.R|FakeOverride|.R|/Ann.foo|() - lval x1: R|KC| = R|/id|(R|/kc|) - lval x2: R|KC| = R|/kc|.R|/idR|() - lval x3: R|KC| = R|/kc|.R|/idP| + R|/id|(R|/kc|).R|FakeOverride|.R|/Ann.foo|() + R|/kc|.R|/idR|().R|FakeOverride|.R|/Ann.foo|() + R|/kc|.R|/idP|.R|FakeOverride|.R|/Ann.foo|() + lval x1: R|KC| = R|/id|(R|/kc|) + lval x2: R|KC| = R|/kc|.R|/idR|() + lval x3: R|KC| = R|/kc|.R|/idP| } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/capturedFlexible.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/capturedFlexible.txt index 8feedf5b318..a287c0292f3 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/capturedFlexible.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/capturedFlexible.txt @@ -1,4 +1,4 @@ FILE: capturedFlexible.kt public final fun foo(z: R|java/util/zip/ZipFile|): R|kotlin/Unit| { - R|/z|.R|java/util/zip/ZipFile.entries|().R|kotlin/sequences/asSequence|!)|>() + R|/z|.R|java/util/zip/ZipFile.entries|().R|kotlin/sequences/asSequence|!|>() } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/withInInitializer.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/withInInitializer.txt index a9d6980bd18..ff724bdb98d 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/withInInitializer.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/withInInitializer.txt @@ -13,7 +13,7 @@ FILE: withInInitializer.kt super() } - public final val list: R|kotlin/collections/List & java/io/Serializable)>| = R|kotlin/collections/listOf| & java/io/Serializable)|>(vararg(Int(1), Int(2), Int(3), String())) + public final val list: R|kotlin/collections/List & java/io/Serializable)>| = R|kotlin/collections/listOf| & java/io/Serializable)|>(vararg(Int(1), Int(2), Int(3), String())) public get(): R|kotlin/collections/List & java/io/Serializable)>| public final val data: R|First| = R|/First.First|(Int(42)) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index b66b5025772..e1ca20624ec 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -424,7 +424,13 @@ class FirCallCompletionResultsWriterTransformer( return declaration.typeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) } .map { candidate.substitutor.substituteOrSelf(it) } - .map { finalSubstitutor.substituteOrSelf(it) } + .map { + finalSubstitutor.substituteOrSelf(it).let { substitutedType -> + typeApproximator.approximateToSuperType( + substitutedType, TypeApproximatorConfiguration.FinalApproximationAfterResolutionAndInference, + ) as ConeKotlinType? ?: substitutedType + } + } } override fun transformAnonymousFunction( diff --git a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt index bc66ab5b44e..328c47db91e 100644 --- a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt +++ b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt @@ -154,7 +154,7 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt TYPE_OP type=kotlin.collections.Collection<.ComponentDescriptor>? origin=SAFE_CAST typeOperand=kotlin.collections.Collection<.ComponentDescriptor> CALL 'public open fun get (p0: kotlin.Any?): V of java.util.HashMap? [operator] declared in java.util.HashMap' type=kotlin.Any? origin=null $this: CALL 'private final fun (): java.util.HashMap declared in ' type=java.util.HashMap origin=GET_PROPERTY - p0: CALL 'public final fun (): java.lang.Class.PlatformExtensionsClashResolver> declared in .PlatformExtensionsClashResolver' type=java.lang.Class<.PlatformSpecificExtension.PlatformExtensionsClashResolver>> origin=GET_PROPERTY + p0: CALL 'public final fun (): java.lang.Class.PlatformExtensionsClashResolver> declared in .PlatformExtensionsClashResolver' type=java.lang.Class.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension>>>>> origin=GET_PROPERTY $this: GET_VAR 'val resolver: .PlatformExtensionsClashResolver<*> [val] declared in .resolveClashesIfAny' type=.PlatformExtensionsClashResolver<*> origin=null WHEN type=kotlin.collections.Collection<.ComponentDescriptor> origin=ELVIS BRANCH @@ -166,9 +166,9 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt if: CONST Boolean type=kotlin.Boolean value=true then: TYPE_OP type=kotlin.collections.Collection<.ComponentDescriptor> origin=IMPLICIT_CAST typeOperand=kotlin.collections.Collection<.ComponentDescriptor> GET_VAR 'val tmp_1: kotlin.collections.Collection<.ComponentDescriptor>? [val] declared in .resolveClashesIfAny' type=kotlin.collections.Collection<.ComponentDescriptor>? origin=null - VAR name:substituteDescriptor type:.ClashResolutionDescriptor.PlatformSpecificExtension.PlatformExtensionsClashResolver>> [val] - CONSTRUCTOR_CALL 'public constructor (container: .ComponentContainer, resolver: .PlatformExtensionsClashResolver.ClashResolutionDescriptor>, clashedComponents: kotlin.collections.List<.ComponentDescriptor>) [primary] declared in .ClashResolutionDescriptor' type=.ClashResolutionDescriptor.PlatformSpecificExtension.PlatformExtensionsClashResolver>> origin=null - : .PlatformSpecificExtension.PlatformExtensionsClashResolver> + VAR name:substituteDescriptor type:.ClashResolutionDescriptor.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension>>>>> [val] + CONSTRUCTOR_CALL 'public constructor (container: .ComponentContainer, resolver: .PlatformExtensionsClashResolver.ClashResolutionDescriptor>, clashedComponents: kotlin.collections.List<.ComponentDescriptor>) [primary] declared in .ClashResolutionDescriptor' type=.ClashResolutionDescriptor.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension>>>>> origin=null + : .PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension>>>> container: GET_VAR 'container: .ComponentContainer declared in .resolveClashesIfAny' type=.ComponentContainer origin=null resolver: GET_VAR 'val resolver: .PlatformExtensionsClashResolver<*> [val] declared in .resolveClashesIfAny' type=.PlatformExtensionsClashResolver<*> origin=null clashedComponents: CALL 'public final fun toList (): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List<.ComponentDescriptor> origin=null