[FIR] Fix NPE on invalid gets with index

^KT-60342 fixed
This commit is contained in:
Egor Kulikov
2023-10-02 15:10:01 +02:00
committed by Space Team
parent 319fb967ec
commit 057973f4bb
7 changed files with 36 additions and 1 deletions
@@ -100,6 +100,12 @@ public class Fe10IdeNormalAnalysisSourceModuleHLExpressionTypeTestGenerated exte
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/inParens.kt");
}
@Test
@TestMetadata("incompleteGet.kt")
public void testIncompleteGet() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/incompleteGet.kt");
}
@Test
@TestMetadata("insideStringTemplate.kt")
public void testInsideStringTemplate() throws Exception {
@@ -154,7 +154,7 @@ internal class KtFirExpressionTypeProvider(
val assignment = expression.parent as? KtBinaryExpression ?: return null
if (assignment.operationToken !in KtTokens.ALL_ASSIGNMENTS) return null
if (assignment.left != expression) return null
val setTargetParameterType = fir.argumentsToSubstitutedValueParameters()?.values?.last()?.substitutedType ?: return null
val setTargetParameterType = fir.argumentsToSubstitutedValueParameters()?.values?.lastOrNull()?.substitutedType ?: return null
return setTargetParameterType.asKtType()
}
@@ -100,6 +100,12 @@ public class FirIdeDependentAnalysisSourceModuleHLExpressionTypeTestGenerated ex
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/inParens.kt");
}
@Test
@TestMetadata("incompleteGet.kt")
public void testIncompleteGet() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/incompleteGet.kt");
}
@Test
@TestMetadata("insideStringTemplate.kt")
public void testInsideStringTemplate() throws Exception {
@@ -100,6 +100,12 @@ public class FirIdeNormalAnalysisSourceModuleHLExpressionTypeTestGenerated exten
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/inParens.kt");
}
@Test
@TestMetadata("incompleteGet.kt")
public void testIncompleteGet() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/incompleteGet.kt");
}
@Test
@TestMetadata("insideStringTemplate.kt")
public void testInsideStringTemplate() throws Exception {
@@ -100,6 +100,12 @@ public class FirStandaloneNormalAnalysisSourceModuleHLExpressionTypeTestGenerate
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/inParens.kt");
}
@Test
@TestMetadata("incompleteGet.kt")
public void testIncompleteGet() throws Exception {
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/incompleteGet.kt");
}
@Test
@TestMetadata("insideStringTemplate.kt")
public void testInsideStringTemplate() throws Exception {
@@ -0,0 +1,9 @@
class Incomplete {
fun get{}
}
fun main(args: Array<String>) {
var incomplete: Incomplete = Incomplete(1)
<expr>incomplete[0]</expr> += 1
}
@@ -0,0 +1,2 @@
expression: incomplete[0]
type: kotlin.Unit