Fix CANNOT_CHECK_FOR_ERASED for when()

This commit is contained in:
Andrey Breslav
2012-08-31 14:23:02 +04:00
parent 002f34e6f5
commit 859dbc87d4
3 changed files with 22 additions and 9 deletions
@@ -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