[Analysis API] fix "Unexpected class FirTypeProjectionWithVarianceImpl" exception
from KtFirExpressionTypeProvider.getKtExpressionType ^KTIJ-23432 fixed
This commit is contained in:
+6
@@ -232,6 +232,12 @@ public class Fe10IdeNormalAnalysisSourceModuleHLExpressionTypeTestGenerated exte
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/stringLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("underscoreTypeArgument.kt")
|
||||
public void testUnderscoreTypeArgument() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/underscoreTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedSuper_multipleSuperTypes.kt")
|
||||
public void testUnresolvedSuper_multipleSuperTypes() throws Exception {
|
||||
|
||||
+3
@@ -83,6 +83,9 @@ internal class KtFirExpressionTypeProvider(
|
||||
// `false` does not have a corresponding elements on the FIR side and hence the containing `FirWhenBranch` is returned. In this
|
||||
// case, we simply report null since FIR does not know about it.
|
||||
is FirWhenBranch -> null
|
||||
|
||||
// `listOf<_>(1)` where `expression` is `_`
|
||||
is FirPlaceholderProjection -> null
|
||||
else -> error("Unexpected ${fir?.let { it::class }} for ${expression::class} with text `${expression.text}`")
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -232,6 +232,12 @@ public class FirIdeDependentAnalysisSourceModuleHLExpressionTypeTestGenerated ex
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/stringLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("underscoreTypeArgument.kt")
|
||||
public void testUnderscoreTypeArgument() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/underscoreTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedSuper_multipleSuperTypes.kt")
|
||||
public void testUnresolvedSuper_multipleSuperTypes() throws Exception {
|
||||
|
||||
+6
@@ -232,6 +232,12 @@ public class FirIdeNormalAnalysisSourceModuleHLExpressionTypeTestGenerated exten
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/stringLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("underscoreTypeArgument.kt")
|
||||
public void testUnderscoreTypeArgument() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/underscoreTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedSuper_multipleSuperTypes.kt")
|
||||
public void testUnresolvedSuper_multipleSuperTypes() throws Exception {
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
abstract class AbstractHLExpressionTypeTest : AbstractAnalysisApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
|
||||
val selected = testServices.expressionMarkerProvider.getSelectedElement(ktFile).let {
|
||||
val selected = testServices.expressionMarkerProvider.getSelectedElementOfTypeByDirective(ktFile, module).let {
|
||||
if (it is KtBlockExpression && it.statements.size == 1 && it.textRange == it.statements.single().textRange) {
|
||||
it.statements.single()
|
||||
} else {
|
||||
@@ -31,7 +31,7 @@ abstract class AbstractHLExpressionTypeTest : AbstractAnalysisApiSingleFileTest(
|
||||
is KtExpression -> selected
|
||||
is KtValueArgument -> selected.getArgumentExpression()
|
||||
else -> null
|
||||
} ?: error("expect an expression but got ${selected.text}")
|
||||
} ?: error("expect an expression but got ${selected.text}, ${selected::class.java}")
|
||||
val type = executeOnPooledThreadInReadAction {
|
||||
analyseForTest(expression) { expression.getKtType()?.render(renderer, position = Variance.INVARIANT) }
|
||||
}
|
||||
|
||||
+6
@@ -232,6 +232,12 @@ public class FirStandaloneNormalAnalysisSourceModuleHLExpressionTypeTestGenerate
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/stringLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("underscoreTypeArgument.kt")
|
||||
public void testUnderscoreTypeArgument() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/underscoreTypeArgument.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedSuper_multipleSuperTypes.kt")
|
||||
public void testUnresolvedSuper_multipleSuperTypes() throws Exception {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// LOOK_UP_FOR_ELEMENT_OF_TYPE: KtNameReferenceExpression
|
||||
|
||||
fun main() {
|
||||
listOf<<expr>_</expr>>(1)
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: _
|
||||
type: null
|
||||
Reference in New Issue
Block a user