Fix CANNOT_CHECK_FOR_ERASED for when()
This commit is contained in:
+3
-4
@@ -214,6 +214,9 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (typeReference == null) return;
|
||||
JetType type = context.expressionTypingServices.getTypeResolver().resolveType(context.scope, typeReference, context.trace, true);
|
||||
checkTypeCompatibility(type, subjectType, typePattern);
|
||||
if (BasicExpressionTypingVisitor.isCastErased(subjectType, type, JetTypeChecker.INSTANCE)) {
|
||||
context.trace.report(Errors.CANNOT_CHECK_FOR_ERASED.on(typeReference, type));
|
||||
}
|
||||
result.set(Pair.create(context.dataFlowInfo.establishSubtyping(subjectVariables, type), context.dataFlowInfo));
|
||||
}
|
||||
|
||||
@@ -334,10 +337,6 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (type == JetStandardClasses.getNullableNothingType() && !subjectType.isNullable()) {
|
||||
context.trace.report(SENSELESS_NULL_IN_WHEN.on(reportErrorOn));
|
||||
}
|
||||
|
||||
if (BasicExpressionTypingVisitor.isCastErased(subjectType, type, JetTypeChecker.INSTANCE)) {
|
||||
context.trace.report(Errors.CANNOT_CHECK_FOR_ERASED.on(reportErrorOn, type));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
enum class List<out T>(val size : Int) {
|
||||
Nil : List<Nothing>(0)
|
||||
}
|
||||
|
||||
fun List<String>.join() =
|
||||
when (this) {
|
||||
List.Nil -> "[]" // CANNOT_CHECK_FOR_ERASED was reported
|
||||
else -> ""
|
||||
}
|
||||
@@ -183,16 +183,16 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/DelegationNotTotrait.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Delegation_ScopeInitializationOrder.kt")
|
||||
public void testDelegation_ScopeInitializationOrder() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/Delegation_ScopeInitializationOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("DelegationToJavaIface.kt")
|
||||
public void testDelegationToJavaIface() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/DelegationToJavaIface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Delegation_ScopeInitializationOrder.kt")
|
||||
public void testDelegation_ScopeInitializationOrder() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/Delegation_ScopeInitializationOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("DiamondFunction.kt")
|
||||
public void testDiamondFunction() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/DiamondFunction.kt");
|
||||
@@ -740,6 +740,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/cast/WhenErasedDisallowFromAny.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("WhenWithExpression.kt")
|
||||
public void testWhenWithExpression() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/cast/WhenWithExpression.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/checkArguments")
|
||||
|
||||
Reference in New Issue
Block a user