[FIR] Fix crash caused by cast of raw type to simple type
#KT-66552 Fixed
This commit is contained in:
committed by
Space Team
parent
cec36355b2
commit
786c37286c
+6
@@ -22200,6 +22200,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("rawTypeCrash.kt")
|
||||||
|
public void testRawTypeCrash() {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/j+k/rawTypeCrash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("rawTypeScope.kt")
|
@TestMetadata("rawTypeScope.kt")
|
||||||
public void testRawTypeScope() {
|
public void testRawTypeScope() {
|
||||||
|
|||||||
+6
@@ -22200,6 +22200,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("rawTypeCrash.kt")
|
||||||
|
public void testRawTypeCrash() {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/j+k/rawTypeCrash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("rawTypeScope.kt")
|
@TestMetadata("rawTypeScope.kt")
|
||||||
public void testRawTypeScope() {
|
public void testRawTypeScope() {
|
||||||
|
|||||||
+6
@@ -22194,6 +22194,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("rawTypeCrash.kt")
|
||||||
|
public void testRawTypeCrash() {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/j+k/rawTypeCrash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("rawTypeScope.kt")
|
@TestMetadata("rawTypeScope.kt")
|
||||||
public void testRawTypeScope() {
|
public void testRawTypeScope() {
|
||||||
|
|||||||
+6
@@ -22200,6 +22200,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("rawTypeCrash.kt")
|
||||||
|
public void testRawTypeCrash() {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/j+k/rawTypeCrash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("rawTypeScope.kt")
|
@TestMetadata("rawTypeScope.kt")
|
||||||
public void testRawTypeScope() {
|
public void testRawTypeScope() {
|
||||||
|
|||||||
+19
-2
@@ -141,8 +141,25 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
|||||||
containingDeclarationSymbol !is FirSyntheticFunctionSymbol &&
|
containingDeclarationSymbol !is FirSyntheticFunctionSymbol &&
|
||||||
typeParameter.shouldBeFlexible(session.typeContext)
|
typeParameter.shouldBeFlexible(session.typeContext)
|
||||||
) {
|
) {
|
||||||
val notNullType = type.withNullability(ConeNullability.NOT_NULL, session.typeContext) as ConeSimpleKotlinType
|
when (type) {
|
||||||
ConeFlexibleType(notNullType, notNullType.withNullability(ConeNullability.NULLABLE, session.typeContext))
|
is ConeSimpleKotlinType -> ConeFlexibleType(
|
||||||
|
type.withNullability(ConeNullability.NOT_NULL, session.typeContext),
|
||||||
|
type.withNullability(ConeNullability.NULLABLE, session.typeContext)
|
||||||
|
)
|
||||||
|
/*
|
||||||
|
* ConeFlexibleTypes have to be handled here
|
||||||
|
* at least because MapTypeArguments special-cases ConeRawTypes without explicit arguments (KT-54666)
|
||||||
|
* which allows them to get past the NoExplicitArguments optimization
|
||||||
|
* in CreateFreshTypeVariableSubstitutorStage.check
|
||||||
|
*
|
||||||
|
* (it might be safe to just return the same flexible type without explicitly enforcing flexibility,
|
||||||
|
* but better safe than sorry when dealing with raw types)
|
||||||
|
*/
|
||||||
|
is ConeFlexibleType -> ConeFlexibleType(
|
||||||
|
type.lowerBound.withNullability(ConeNullability.NOT_NULL, session.typeContext),
|
||||||
|
type.upperBound.withNullability(ConeNullability.NULLABLE, session.typeContext)
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
type
|
type
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// ISSUE: KT-66552
|
||||||
|
|
||||||
|
// FILE: JsStubElementType.java
|
||||||
|
public interface JsStubElementType<E, S extends JsStubElement<E>> {}
|
||||||
|
|
||||||
|
// FILE: JsStubElement.java
|
||||||
|
public interface JsStubElement<T> {
|
||||||
|
<E, S extends JsStubElement<E>> void findChildStubByType(JsStubElementType<E, S> childStubType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: FromJava.java
|
||||||
|
public interface FromJava {
|
||||||
|
JsStubElement RAW_TYPED_STUB = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Kotlin.kt
|
||||||
|
interface JsStubElementSubType: JsStubElement<Any>
|
||||||
|
|
||||||
|
fun test(childStubType: JsStubElementType<Any, JsStubElement<Any>>) {
|
||||||
|
val rawTypedStub = FromJava.RAW_TYPED_STUB
|
||||||
|
if (rawTypedStub is JsStubElementSubType) {
|
||||||
|
rawTypedStub.findChildStubByType(childStubType)
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+6
@@ -22200,6 +22200,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
runTest("compiler/testData/diagnostics/tests/j+k/rawOverride.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("rawTypeCrash.kt")
|
||||||
|
public void testRawTypeCrash() {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/j+k/rawTypeCrash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("rawTypeScope.kt")
|
@TestMetadata("rawTypeScope.kt")
|
||||||
public void testRawTypeScope() {
|
public void testRawTypeScope() {
|
||||||
|
|||||||
Reference in New Issue
Block a user