diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index 5bf59c75fc0..f171c1340c8 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java @@ -260,6 +260,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt"); } + @Test + @TestMetadata("implicitTypeWithTypeBound.kt") + public void testImplicitTypeWithTypeBound() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.kt"); + } + @Test @TestMetadata("incorrectDataClass.kt") public void testIncorrectDataClass() throws Exception { diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 692c9f042b0..ad722c0ced1 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -224,6 +224,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt"); } + @TestMetadata("implicitTypeWithTypeBound.kt") + public void testImplicitTypeWithTypeBound() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.kt"); + } + @TestMetadata("incorrectDataClass.kt") public void testIncorrectDataClass() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/incorrectDataClass.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.fir.txt b/compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.fir.txt new file mode 100644 index 00000000000..1fec06e357c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.fir.txt @@ -0,0 +1,18 @@ +FILE: main.kt + public final fun myRun(action: R|() -> T|): R|T| { + ^myRun R|/action|.R|SubstitutionOverride|() + } + public final fun test(other: R|TypeWithBoundedGeneric<*>|): R|TypeWithBoundedGeneric<*>| { + ^test R|/myRun||>( = myRun@fun (): R|TypeWithBoundedGeneric<*>| { + ^ R|/other| + } + ) + } + public abstract interface SomeType : R|kotlin/Any| { + } + public abstract class TypeWithBoundedGeneric : R|kotlin/Any| { + public constructor(): R|TypeWithBoundedGeneric| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.kt b/compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.kt new file mode 100644 index 00000000000..fc58129f882 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.kt @@ -0,0 +1,8 @@ +// FILE: main.kt +fun myRun(action: () -> T): T = action() + +fun test(other: TypeWithBoundedGeneric<*>) = myRun { other } + +interface SomeType + +abstract class TypeWithBoundedGeneric diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index e9d8f8788bf..307cac60e79 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -260,6 +260,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt"); } + @Test + @TestMetadata("implicitTypeWithTypeBound.kt") + public void testImplicitTypeWithTypeBound() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.kt"); + } + @Test @TestMetadata("incorrectDataClass.kt") public void testIncorrectDataClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index dabad62f71b..2c4e61877fa 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -260,6 +260,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeInFakeOverride.kt"); } + @Test + @TestMetadata("implicitTypeWithTypeBound.kt") + public void testImplicitTypeWithTypeBound() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/implicitTypeWithTypeBound.kt"); + } + @Test @TestMetadata("incorrectDataClass.kt") public void testIncorrectDataClass() 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 a04392d60ef..1f2b397b3dd 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 @@ -274,7 +274,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty return when (this) { is ConeStubTypeConstructor -> listOf(session.builtinTypes.nullableAnyType.type) is ConeTypeVariableTypeConstructor -> emptyList() - is ConeTypeParameterLookupTag -> symbol.fir.bounds.map { it.coneType } + is ConeTypeParameterLookupTag -> symbol.resolvedBounds.map { it.coneType } is ConeClassLikeLookupTag -> { when (val symbol = toClassLikeSymbol().also { it?.ensureResolved(FirResolvePhase.TYPES) }) { is FirClassSymbol<*> -> symbol.fir.superConeTypes @@ -308,17 +308,17 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeParameterMarker.upperBoundCount(): Int { require(this is ConeTypeParameterLookupTag) - return this.symbol.fir.bounds.size + return this.symbol.resolvedBounds.size } override fun TypeParameterMarker.getUpperBound(index: Int): KotlinTypeMarker { require(this is ConeTypeParameterLookupTag) - return this.symbol.fir.bounds[index].coneType + return this.symbol.resolvedBounds[index].coneType } override fun TypeParameterMarker.getUpperBounds(): List { require(this is ConeTypeParameterLookupTag) - return this.symbol.fir.bounds.map { it.coneType } + return this.symbol.resolvedBounds.map { it.coneType } } override fun TypeParameterMarker.getTypeConstructor(): TypeConstructorMarker { @@ -328,7 +328,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeParameterMarker.hasRecursiveBounds(selfConstructor: TypeConstructorMarker?): Boolean { require(this is ConeTypeParameterLookupTag) - return this.typeParameterSymbol.fir.bounds.any { typeRef -> + return this.typeParameterSymbol.resolvedBounds.any { typeRef -> typeRef.coneType.contains { it.typeConstructor() == this.getTypeConstructor() } && (selfConstructor == null || typeRef.coneType.typeConstructor() == selfConstructor) } @@ -484,7 +484,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } private fun FirTypeParameterSymbol.allBoundsAreNullable(): Boolean { - return fir.bounds.all { it.coneType.isNullableType() } + return resolvedBounds.all { it.coneType.isNullableType() } } private fun TypeConstructorMarker.toFirRegularClass(): FirRegularClass? { @@ -553,7 +553,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeParameterMarker.getRepresentativeUpperBound(): KotlinTypeMarker { require(this is ConeTypeParameterLookupTag) - return this.symbol.fir.bounds.getOrNull(0)?.coneType + return this.symbol.resolvedBounds.getOrNull(0)?.coneType ?: session.builtinTypes.nullableAnyType.type }