Fix for 'null is Nothing' false-positive

This commit is contained in:
Andrey Breslav
2011-04-15 19:09:22 +04:00
parent 3678b343b6
commit fad3030e37
2 changed files with 9 additions and 2 deletions
@@ -120,7 +120,6 @@ public class JetTypeInferrer {
return resolutionResult.isSuccess() ? resolutionResult.getFunctionDescriptor() : null;
}
private OverloadDomain getOverloadDomain(
@NotNull final JetScope scope,
@NotNull JetExpression calleeExpression,
@@ -409,7 +408,7 @@ public class JetTypeInferrer {
expression.accept(this);
if (result != null) {
trace.recordExpressionType(expression, result);
if (JetStandardClasses.isNothing(result)) {
if (JetStandardClasses.isNothing(result) && !result.isNullable()) {
markDominatedExpressionsAsUnreachable(expression);
}
}
@@ -151,3 +151,11 @@ fun foo(a : Nothing) : Unit {
fun fail() : Nothing {
throw new java.lang.RuntimeException()
}
fun nullIsNotNothing() : Unit {
val x : Int? = 1
if (x != null) {
return
}
fail()
}