FIR LL API: resolve PSI elements to more specific FIR element

Compound access and implicit delegated constructor are mapped to FIR
elements that are way too broad.
This commit is contained in:
Tianyu Geng
2021-11-22 21:03:21 -08:00
committed by Ilya Kirillov
parent e8f1af6140
commit bc95733818
27 changed files with 252 additions and 1 deletions
@@ -54,6 +54,13 @@ internal class KtFirExpressionTypeProvider(
fir.typeRef.coneType.asKtType()
}
}
is FirVariableAssignment -> {
if (expression is KtUnaryExpression && expression.operationToken in KtTokens.INCREMENT_AND_DECREMENT) {
fir.rValue.typeRef.coneType.asKtType()
} else {
analysisSession.builtinTypes.UNIT
}
}
is FirExpression -> fir.typeRef.coneType.asKtType()
is FirNamedReference -> fir.getReferencedElementType(firResolveState).asKtType()
is FirStatement -> with(analysisSession) { builtinTypes.UNIT }
@@ -120,6 +120,24 @@ public class FirHLExpressionTypeTestGenerated extends AbstractFirHLExpressionTyp
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/nonExpression.kt");
}
@Test
@TestMetadata("plusAssign.kt")
public void testPlusAssign() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/plusAssign.kt");
}
@Test
@TestMetadata("postfixDec.kt")
public void testPostfixDec() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/postfixDec.kt");
}
@Test
@TestMetadata("prefixInc.kt")
public void testPrefixInc() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/prefixInc.kt");
}
@Test
@TestMetadata("property.kt")
public void testProperty() throws Exception {