[FIR] Resolve where subjects to corresponding type argument

^KTIJ-25295 fixed

Merge-request: KT-MR-10044
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
Egor Kulikov
2023-05-17 15:28:02 +00:00
committed by Space Team
parent bcefa1cd66
commit bff1520c9e
21 changed files with 135 additions and 1 deletions
@@ -73,7 +73,7 @@ internal class KtFirExpressionTypeProvider(
is FirExpression -> fir.typeRef.coneType.asKtType()
is FirNamedReference -> fir.getReferencedElementType().asKtType()
is FirStatement -> with(analysisSession) { builtinTypes.UNIT }
is FirTypeRef, is FirImport, is FirPackageDirective, is FirLabel -> null
is FirTypeRef, is FirImport, is FirPackageDirective, is FirLabel, is FirTypeParameterRef -> null
// For invalid code like the following,
// ```
// when {
@@ -218,6 +218,7 @@ internal object FirReferenceResolveHelper {
is FirResolvable -> getSymbolsByResolvable(fir, expression, session, symbolBuilder)
is FirNamedArgumentExpression -> getSymbolsByNameArgumentExpression(expression, analysisSession, symbolBuilder)
is FirEqualityOperatorCall -> getSymbolsByEqualsName(fir, session, analysisSession, symbolBuilder)
is FirTypeParameter -> getSybmolsByTypeParameter(symbolBuilder, fir)
else -> handleUnknownFirElement(expression, analysisSession, session, symbolBuilder)
}
}
@@ -430,6 +431,13 @@ internal object FirReferenceResolveHelper {
return listOf(symbolBuilder.buildSymbol(fir.symbol))
}
private fun getSybmolsByTypeParameter(
symbolBuilder: KtSymbolByFirBuilder,
fir: FirTypeParameter
): List<KtSymbol> {
return listOf(symbolBuilder.buildSymbol(fir.symbol))
}
private fun getSymbolsByResolvedImport(
expression: KtSimpleNameExpression,
builder: KtSymbolByFirBuilder,
@@ -1950,6 +1950,18 @@ public class FirIdeDependentAnalysisSourceModuleReferenceResolveTestGenerated ex
public void testTypeParameterInFunctionLiteral() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/TypeParameterInFunctionLiteral.kt");
}
@Test
@TestMetadata("whereClause1.kt")
public void testWhereClause1() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/whereClause1.kt");
}
@Test
@TestMetadata("whereClause2.kt")
public void testWhereClause2() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/whereClause2.kt");
}
}
@Nested
@@ -1834,5 +1834,17 @@ public class FirIdeNormalAnalysisLibrarySourceModuleReferenceResolveTestGenerate
public void testTypeParameterInFunctionLiteral() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/TypeParameterInFunctionLiteral.kt");
}
@Test
@TestMetadata("whereClause1.kt")
public void testWhereClause1() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/whereClause1.kt");
}
@Test
@TestMetadata("whereClause2.kt")
public void testWhereClause2() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/whereClause2.kt");
}
}
}
@@ -1950,6 +1950,18 @@ public class FirIdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exten
public void testTypeParameterInFunctionLiteral() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/TypeParameterInFunctionLiteral.kt");
}
@Test
@TestMetadata("whereClause1.kt")
public void testWhereClause1() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/whereClause1.kt");
}
@Test
@TestMetadata("whereClause2.kt")
public void testWhereClause2() throws Exception {
runTest("analysis/analysis-api/testData/referenceResolve/typeParameter/whereClause2.kt");
}
}
@Nested