[FIR] Fix false positive case of CANNOT_CHECK_FOR_ERASED
Restore CANNOT_CHECK_FOR_ERASED as error
This commit is contained in:
committed by
teamcityserver
parent
850d76f6bf
commit
f05436b939
+6
@@ -4095,6 +4095,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/cast/IsErasedAllowFromOut2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IsErasedAllowFromOut3.kt")
|
||||
public void testIsErasedAllowFromOut3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/cast/IsErasedAllowFromOut3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IsErasedAllowFromOutAtClass.kt")
|
||||
public void testIsErasedAllowFromOutAtClass() throws Exception {
|
||||
|
||||
+6
@@ -4095,6 +4095,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/cast/IsErasedAllowFromOut2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IsErasedAllowFromOut3.kt")
|
||||
public void testIsErasedAllowFromOut3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/cast/IsErasedAllowFromOut3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("IsErasedAllowFromOutAtClass.kt")
|
||||
public void testIsErasedAllowFromOutAtClass() throws Exception {
|
||||
|
||||
+1
-1
@@ -1102,7 +1102,7 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
||||
}
|
||||
|
||||
val CASTS_AND_IS_CHECKS by object : DiagnosticGroup("Casts and is-checks") {
|
||||
val CANNOT_CHECK_FOR_ERASED by warning<PsiElement> {
|
||||
val CANNOT_CHECK_FOR_ERASED by error<PsiElement> {
|
||||
parameter<ConeKotlinType>("type")
|
||||
}
|
||||
val CAST_NEVER_SUCCEEDS by warning<KtBinaryExpressionWithTypeRHS>(PositioningStrategy.OPERATOR)
|
||||
|
||||
+1
-1
@@ -590,7 +590,7 @@ object FirErrors {
|
||||
val USELESS_ELVIS_RIGHT_IS_NULL by warning0<KtBinaryExpression>(SourceElementPositioningStrategies.USELESS_ELVIS)
|
||||
|
||||
// Casts and is-checks
|
||||
val CANNOT_CHECK_FOR_ERASED by warning1<PsiElement, ConeKotlinType>()
|
||||
val CANNOT_CHECK_FOR_ERASED by error1<PsiElement, ConeKotlinType>()
|
||||
val CAST_NEVER_SUCCEEDS by warning0<KtBinaryExpressionWithTypeRHS>(SourceElementPositioningStrategies.OPERATOR)
|
||||
val USELESS_CAST by warning0<KtBinaryExpressionWithTypeRHS>(SourceElementPositioningStrategies.AS_TYPE)
|
||||
val UNCHECKED_CAST by warning2<KtBinaryExpressionWithTypeRHS, ConeKotlinType, ConeKotlinType>(SourceElementPositioningStrategies.AS_TYPE)
|
||||
|
||||
+5
-10
@@ -237,17 +237,12 @@ fun findStaticallyKnownSubtype(
|
||||
// If some parameters are not determined by unification, it means that these parameters are lost,
|
||||
// let's put ConeStubType instead, so that we can only cast to something like List<*>, e.g. (a: Any) as List<*>
|
||||
for (variable in variables) {
|
||||
val value = substitution[variable]
|
||||
val resultValue = if (value == null) {
|
||||
if (!resultSubstitution.containsKey(variable)) {
|
||||
context.session.builtinTypes.nullableAnyType.type
|
||||
} else {
|
||||
null
|
||||
val resultValue = when (val value = substitution[variable]) {
|
||||
null -> null
|
||||
is ConeStarProjection -> {
|
||||
ConeStubTypeForTypeVariableInSubtyping(ConeTypeVariable("", null), ConeNullability.NULLABLE)
|
||||
}
|
||||
} else if (value is ConeStarProjection) {
|
||||
ConeStubTypeForTypeVariableInSubtyping(ConeTypeVariable("", variable.toLookupTag()), ConeNullability.NULLABLE)
|
||||
} else {
|
||||
value.type
|
||||
else -> value.type
|
||||
}
|
||||
if (resultValue != null) {
|
||||
resultSubstitution[variable] = resultValue
|
||||
|
||||
+2
-1
@@ -606,7 +606,8 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
|
||||
private fun FirTypeRef.withTypeArgumentsForBareType(argument: FirExpression, operation: FirOperation): FirTypeRef {
|
||||
val type = coneTypeSafe<ConeClassLikeType>() ?: return this
|
||||
if (type.typeArguments.isNotEmpty()) return this
|
||||
if (type.typeArguments.isNotEmpty()) return this // TODO: Incorrect for local classes.
|
||||
// TODO: Check equality of size of arguments and parameters?
|
||||
|
||||
val firClass = type.lookupTag.toSymbol(session)?.fir ?: return this
|
||||
if (firClass.typeParameters.isEmpty()) return this
|
||||
|
||||
Reference in New Issue
Block a user