fixed bug in 'DataFlowInfo.getPossibleTypes'

parent types should be enriched as well
This commit is contained in:
Svetlana Isakova
2013-12-09 17:07:47 +04:00
parent 4a26c9df04
commit cd6934bee8
3 changed files with 17 additions and 3 deletions
@@ -102,9 +102,10 @@ import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NUL
@Override
@NotNull
public Set<JetType> getPossibleTypes(@NotNull DataFlowValue key) {
Set<JetType> types = typeInfo.get(key);
Set<JetType> theseTypes = typeInfo.get(key);
Set<JetType> types = parent == null ? theseTypes : Sets.union(theseTypes, parent.getPossibleTypes(key));
if (getNullability(key).canBeNull()) {
return parent == null ? types : Sets.union(types, parent.getPossibleTypes(key));
return types;
}
Set<JetType> enrichedTypes = Sets.newHashSetWithExpectedSize(types.size() + 1);
@@ -116,7 +117,7 @@ import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NUL
enrichedTypes.add(TypeUtils.makeNotNullable(type));
}
return parent == null ? enrichedTypes : Sets.union(enrichedTypes, parent.getPossibleTypes(key));
return enrichedTypes;
}
@Override
@@ -0,0 +1,8 @@
fun foo(d: Any?) {
if (d is String?) {
<!DEBUG_INFO_AUTOCAST!>d<!>!!
doString(<!DEBUG_INFO_AUTOCAST!>d<!>)
}
}
fun doString(s: String) = s
@@ -4577,6 +4577,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/AssertNotNull.kt");
}
@TestMetadata("dataFlowInfoAfterExclExcl.kt")
public void testDataFlowInfoAfterExclExcl() throws Exception {
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/dataFlowInfoAfterExclExcl.kt");
}
@TestMetadata("equalityUnderNotNullCheck.kt")
public void testEqualityUnderNotNullCheck() throws Exception {
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.kt");