fixed bug in 'DataFlowInfo.getPossibleTypes'
parent types should be enriched as well
This commit is contained in:
+4
-3
@@ -102,9 +102,10 @@ import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NUL
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<JetType> getPossibleTypes(@NotNull DataFlowValue key) {
|
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()) {
|
if (getNullability(key).canBeNull()) {
|
||||||
return parent == null ? types : Sets.union(types, parent.getPossibleTypes(key));
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<JetType> enrichedTypes = Sets.newHashSetWithExpectedSize(types.size() + 1);
|
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));
|
enrichedTypes.add(TypeUtils.makeNotNullable(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent == null ? enrichedTypes : Sets.union(enrichedTypes, parent.getPossibleTypes(key));
|
return enrichedTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+8
@@ -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");
|
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")
|
@TestMetadata("equalityUnderNotNullCheck.kt")
|
||||||
public void testEqualityUnderNotNullCheck() throws Exception {
|
public void testEqualityUnderNotNullCheck() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.kt");
|
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/equalityUnderNotNullCheck.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user