[FIR LT] Fix crash in incomplete when condition without type
#KT-58908 Fixed
This commit is contained in:
committed by
Space Team
parent
be232d3e6f
commit
896f8853ae
+6
@@ -3817,6 +3817,12 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incompleteWhen.kt")
|
||||||
|
public void testIncompleteWhen() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassHierarchy.kt")
|
@TestMetadata("innerClassHierarchy.kt")
|
||||||
public void testInnerClassHierarchy() throws Exception {
|
public void testInnerClassHierarchy() throws Exception {
|
||||||
|
|||||||
+6
@@ -3817,6 +3817,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incompleteWhen.kt")
|
||||||
|
public void testIncompleteWhen() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassHierarchy.kt")
|
@TestMetadata("innerClassHierarchy.kt")
|
||||||
public void testInnerClassHierarchy() throws Exception {
|
public void testInnerClassHierarchy() throws Exception {
|
||||||
|
|||||||
+5
@@ -3356,6 +3356,11 @@ public class LazyBodyIsNotTouchedTestGenerated extends AbstractLazyBodyIsNotTouc
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("incompleteWhen.kt")
|
||||||
|
public void testIncompleteWhen() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("innerClassHierarchy.kt")
|
@TestMetadata("innerClassHierarchy.kt")
|
||||||
public void testInnerClassHierarchy() throws Exception {
|
public void testInnerClassHierarchy() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt");
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
FILE: incompleteWhen.kt
|
||||||
|
public final fun main(args: R|kotlin/Array<kotlin/String>|): R|kotlin/Unit| {
|
||||||
|
lval x: R|kotlin/Int| = Int(42)
|
||||||
|
when (R|<local>/x|) {
|
||||||
|
($subj$ is <ERROR TYPE REF: Incomplete code>) -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
val x = 42
|
||||||
|
when (x) {is<!SYNTAX!><!>}
|
||||||
|
}
|
||||||
+6
@@ -3817,6 +3817,12 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incompleteWhen.kt")
|
||||||
|
public void testIncompleteWhen() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassHierarchy.kt")
|
@TestMetadata("innerClassHierarchy.kt")
|
||||||
public void testInnerClassHierarchy() throws Exception {
|
public void testInnerClassHierarchy() throws Exception {
|
||||||
|
|||||||
+6
@@ -3817,6 +3817,12 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incompleteWhen.kt")
|
||||||
|
public void testIncompleteWhen() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("innerClassHierarchy.kt")
|
@TestMetadata("innerClassHierarchy.kt")
|
||||||
public void testInnerClassHierarchy() throws Exception {
|
public void testInnerClassHierarchy() throws Exception {
|
||||||
|
|||||||
+3
-2
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
|||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
|
import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||||
import org.jetbrains.kotlin.name.CallableId
|
import org.jetbrains.kotlin.name.CallableId
|
||||||
import org.jetbrains.kotlin.name.SpecialNames
|
import org.jetbrains.kotlin.name.SpecialNames
|
||||||
@@ -912,7 +913,7 @@ class ExpressionsConverter(
|
|||||||
hasSubject: Boolean,
|
hasSubject: Boolean,
|
||||||
): WhenConditionConvertedResults {
|
): WhenConditionConvertedResults {
|
||||||
lateinit var firOperation: FirOperation
|
lateinit var firOperation: FirOperation
|
||||||
lateinit var firType: FirTypeRef
|
var firType: FirTypeRef? = null
|
||||||
whenCondition.forEachChildren {
|
whenCondition.forEachChildren {
|
||||||
when (it.tokenType) {
|
when (it.tokenType) {
|
||||||
TYPE_REFERENCE -> firType = declarationsConverter.convertType(it)
|
TYPE_REFERENCE -> firType = declarationsConverter.convertType(it)
|
||||||
@@ -929,7 +930,7 @@ class ExpressionsConverter(
|
|||||||
val result = buildTypeOperatorCall {
|
val result = buildTypeOperatorCall {
|
||||||
source = whenCondition.toFirSourceElement()
|
source = whenCondition.toFirSourceElement()
|
||||||
operation = firOperation
|
operation = firOperation
|
||||||
conversionTypeRef = firType
|
conversionTypeRef = firType ?: buildErrorTypeRef { diagnostic = ConeSyntaxDiagnostic("Incomplete code") }
|
||||||
argumentList = buildUnaryArgumentList(subjectExpression)
|
argumentList = buildUnaryArgumentList(subjectExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user