diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionCallWithGenericResult.kt b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionCallWithGenericResult.kt new file mode 100644 index 00000000000..8f39a6f220d --- /dev/null +++ b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionCallWithGenericResult.kt @@ -0,0 +1,9 @@ +open class Foo + +fun bar(): Foo? { + return null +} + +fun resolveMe() { + val x = bar() +} diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionCallWithGenericResult.txt b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionCallWithGenericResult.txt new file mode 100644 index 00000000000..f3b4f747dcf --- /dev/null +++ b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionCallWithGenericResult.txt @@ -0,0 +1,170 @@ + +RAW_FIR: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +IMPORTS: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +COMPILER_REQUIRED_ANNOTATIONS: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public? final? [COMPILER_REQUIRED_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +COMPANION_GENERATION: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public? final? [COMPANION_GENERATION] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +SUPER_TYPES: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public? final? [SUPER_TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +TYPES: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public? final? [TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +STATUS: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public final [STATUS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +ARGUMENTS_OF_ANNOTATIONS: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public final [ARGUMENTS_OF_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +CONTRACTS: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public final [CONTRACTS] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: = bar#() + } + +IMPLICIT_TYPES_BODY_RESOLVE: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public final [IMPLICIT_TYPES_BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: = bar#() + } + +ANNOTATIONS_ARGUMENTS_MAPPING: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public final [ANNOTATIONS_ARGUMENTS_MAPPING] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: = bar#() + } + +EXPECT_ACTUAL_MATCHING: +FILE: functionCallWithGenericResult.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] fun bar(): Foo? { LAZY_BLOCK } + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: = bar#() + } + +BODY_RESOLVE: +FILE: functionCallWithGenericResult.kt + public? open [COMPILER_REQUIRED_ANNOTATIONS] class Foo<[COMPILER_REQUIRED_ANNOTATIONS] T : CharSequence> : R|kotlin/Any| { + public? [COMPILER_REQUIRED_ANNOTATIONS] [ContainingClassKey=Foo] constructor<[COMPILER_REQUIRED_ANNOTATIONS] T : CharSequence>(): R|Foo| { + super() + } + + } + public final [CONTRACTS] fun bar(): R|Foo?| { + ^bar Null(null) + } + public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { + [BODY_RESOLVE] lval x: R|Foo?| = R|/bar|() + } + +FILE RAW TO BODY: +FILE: functionCallWithGenericResult.kt + public open [BODY_RESOLVE] class Foo<[BODY_RESOLVE] T : R|kotlin/CharSequence|> : R|kotlin/Any| { + public [BODY_RESOLVE] [ContainingClassKey=Foo] constructor<[BODY_RESOLVE] T : R|kotlin/CharSequence|>(): R|Foo| { + super() + } + + } + public final [BODY_RESOLVE] fun bar(): R|Foo?| { + ^bar Null(null) + } + public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { + [BODY_RESOLVE] lval x: R|Foo?| = R|/bar|() + } diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionWithGenericExpectedTypeInside.kt b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionWithGenericExpectedTypeInside.kt new file mode 100644 index 00000000000..e86c549ba37 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionWithGenericExpectedTypeInside.kt @@ -0,0 +1,9 @@ +open class Foo + +class Bar : Foo + +fun bar() = Bar() + +fun resolveMe() { + val x: Foo = bar() +} diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionWithGenericExpectedTypeInside.txt b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionWithGenericExpectedTypeInside.txt new file mode 100644 index 00000000000..61568276ea8 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/lazyResolve/functions/functionWithGenericExpectedTypeInside.txt @@ -0,0 +1,253 @@ +RAW_FIR: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +IMPORTS: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +COMPILER_REQUIRED_ANNOTATIONS: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public? final? [COMPILER_REQUIRED_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +COMPANION_GENERATION: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public? final? [COMPANION_GENERATION] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +SUPER_TYPES: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public? final? [SUPER_TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +TYPES: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public? final? [TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +STATUS: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public final [STATUS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +ARGUMENTS_OF_ANNOTATIONS: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public final [ARGUMENTS_OF_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } + +CONTRACTS: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public final [CONTRACTS] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: Foo = bar#() + } + +IMPLICIT_TYPES_BODY_RESOLVE: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public final [IMPLICIT_TYPES_BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: Foo = bar#() + } + +ANNOTATIONS_ARGUMENTS_MAPPING: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public final [ANNOTATIONS_ARGUMENTS_MAPPING] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: Foo = bar#() + } + +EXPECT_ACTUAL_MATCHING: +FILE: functionWithGenericExpectedTypeInside.kt + public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo| { + super() + } + + } + public? final? [RAW_FIR] class Bar : Foo { + public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public? final? [RAW_FIR] fun bar(): { LAZY_BLOCK } + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + [RAW_FIR] lval x: Foo = bar#() + } + +BODY_RESOLVE: +FILE: functionWithGenericExpectedTypeInside.kt + public open [TYPES] class Foo<[TYPES] T : R|kotlin/CharSequence|> : R|kotlin/Any| { + public [TYPES] [ContainingClassKey=Foo] constructor<[TYPES] T : R|kotlin/CharSequence|>(): R|Foo| { + super() + } + + } + public final [TYPES] class Bar : R|Foo| { + public [STATUS] [ContainingClassKey=Bar] constructor(): R|Bar| { + super<>() + } + + } + public final [IMPLICIT_TYPES_BODY_RESOLVE] fun bar(): R|Bar| { + ^bar R|/Bar.Bar|() + } + public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { + [BODY_RESOLVE] lval x: R|Foo| = R|/bar|() + } + +FILE RAW TO BODY: +FILE: functionWithGenericExpectedTypeInside.kt + public open [BODY_RESOLVE] class Foo<[BODY_RESOLVE] T : R|kotlin/CharSequence|> : R|kotlin/Any| { + public [BODY_RESOLVE] [ContainingClassKey=Foo] constructor<[BODY_RESOLVE] T : R|kotlin/CharSequence|>(): R|Foo| { + super() + } + + } + public final [BODY_RESOLVE] class Bar : R|Foo| { + public [BODY_RESOLVE] [ContainingClassKey=Bar] constructor(): R|Bar| { + super|>() + } + + } + public final [BODY_RESOLVE] fun bar(): R|Bar| { + ^bar R|/Bar.Bar|() + } + public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { + [BODY_RESOLVE] lval x: R|Foo| = R|/bar|() + } diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyDeclarationResolveTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyDeclarationResolveTestGenerated.java index d6d890d9546..c0828df4c18 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyDeclarationResolveTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirLazyDeclarationResolveTestGenerated.java @@ -191,6 +191,18 @@ public class FirLazyDeclarationResolveTestGenerated extends AbstractFirLazyDecla KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/lazyResolve/functions"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test + @TestMetadata("functionCallWithGenericResult.kt") + public void testFunctionCallWithGenericResult() throws Exception { + runTest("analysis/low-level-api-fir/testdata/lazyResolve/functions/functionCallWithGenericResult.kt"); + } + + @Test + @TestMetadata("functionWithGenericExpectedTypeInside.kt") + public void testFunctionWithGenericExpectedTypeInside() throws Exception { + runTest("analysis/low-level-api-fir/testdata/lazyResolve/functions/functionWithGenericExpectedTypeInside.kt"); + } + @Test @TestMetadata("functionWithTypeParameters.kt") public void testFunctionWithTypeParameters() throws Exception { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index f01347ca8b3..04f5d1bf13f 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -281,7 +281,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty return when (this) { is ConeStubTypeConstructor -> listOf(session.builtinTypes.nullableAnyType.type) is ConeTypeVariableTypeConstructor -> emptyList() - is ConeTypeParameterLookupTag -> symbol.resolvedBounds.map { it.coneType } + is ConeTypeParameterLookupTag -> bounds().map { it.coneType } is ConeClassLikeLookupTag -> { when (val symbol = toClassLikeSymbol().also { it?.lazyResolveToPhase(FirResolvePhase.TYPES) }) { is FirClassSymbol<*> -> symbol.fir.superConeTypes @@ -315,17 +315,17 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeParameterMarker.upperBoundCount(): Int { require(this is ConeTypeParameterLookupTag) - return this.symbol.resolvedBounds.size + return this.bounds().size } override fun TypeParameterMarker.getUpperBound(index: Int): KotlinTypeMarker { require(this is ConeTypeParameterLookupTag) - return this.symbol.resolvedBounds[index].coneType + return this.bounds()[index].coneType } override fun TypeParameterMarker.getUpperBounds(): List { require(this is ConeTypeParameterLookupTag) - return this.symbol.resolvedBounds.map { it.coneType } + return this.bounds().map { it.coneType } } override fun TypeParameterMarker.getTypeConstructor(): TypeConstructorMarker { @@ -335,7 +335,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeParameterMarker.hasRecursiveBounds(selfConstructor: TypeConstructorMarker?): Boolean { require(this is ConeTypeParameterLookupTag) - return this.typeParameterSymbol.resolvedBounds.any { typeRef -> + return this.bounds().any { typeRef -> typeRef.coneType.contains { it.typeConstructor() == this.getTypeConstructor() } && (selfConstructor == null || typeRef.coneType.typeConstructor() == selfConstructor) } @@ -580,10 +580,13 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeParameterMarker.getRepresentativeUpperBound(): KotlinTypeMarker { require(this is ConeTypeParameterLookupTag) - return this.symbol.resolvedBounds.getOrNull(0)?.coneType + return this.bounds().getOrNull(0)?.coneType ?: session.builtinTypes.nullableAnyType.type } + @Suppress("NOTHING_TO_INLINE") + private inline fun ConeTypeParameterLookupTag.bounds(): List = symbol.fir.bounds + override fun KotlinTypeMarker.getUnsubstitutedUnderlyingType(): KotlinTypeMarker? { require(this is ConeKotlinType) return unsubstitutedUnderlyingTypeForInlineClass(session) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index 38e77efbaf9..ab456f8c128 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.types.builder.* import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl @@ -394,6 +395,7 @@ fun ConeTypeContext.captureArguments(type: ConeKotlinType, status: CaptureStatus if (oldArgument.kind == ProjectionKind.INVARIANT) continue val parameter = typeConstructor.getParameter(index) + (parameter as? ConeTypeParameterLookupTag)?.typeParameterSymbol?.lazyResolveToPhase(FirResolvePhase.TYPES) val upperBounds = (0 until parameter.upperBoundCount()).mapTo(mutableListOf()) { paramIndex -> substitutor.safeSubstitute( this as TypeSystemInferenceExtensionContext, parameter.getUpperBound(paramIndex)