Clear var nullability in loops more accurately #KT-14977 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
dc3ea4b6e4
commit
fbc1d1a844
+1
-1
@@ -146,7 +146,7 @@ internal class DelegatingDataFlowInfo private constructor(
|
|||||||
*/
|
*/
|
||||||
override fun clearValueInfo(value: DataFlowValue, languageVersionSettings: LanguageVersionSettings): DataFlowInfo {
|
override fun clearValueInfo(value: DataFlowValue, languageVersionSettings: LanguageVersionSettings): DataFlowInfo {
|
||||||
val builder = Maps.newHashMap<DataFlowValue, Nullability>()
|
val builder = Maps.newHashMap<DataFlowValue, Nullability>()
|
||||||
putNullability(builder, value, Nullability.UNKNOWN, languageVersionSettings)
|
putNullability(builder, value, value.immanentNullability, languageVersionSettings)
|
||||||
return create(this, ImmutableMap.copyOf(builder), EMPTY_TYPE_INFO, value)
|
return create(this, ImmutableMap.copyOf(builder), EMPTY_TYPE_INFO, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
fun readLine() = "x"
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
var line = ""
|
||||||
|
|
||||||
|
while (<!SENSELESS_COMPARISON!>line != null<!>) {
|
||||||
|
line = readLine()
|
||||||
|
|
||||||
|
if (<!SENSELESS_COMPARISON!>line != null<!>) {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun bar(): kotlin.Unit
|
||||||
|
public fun foo(): kotlin.Unit
|
||||||
|
public fun readLine(): kotlin.String
|
||||||
@@ -19183,6 +19183,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/senselessComparison"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/senselessComparison"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noExplicitType.kt")
|
||||||
|
public void testNoExplicitType() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/senselessComparison/noExplicitType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("parenthesized.kt")
|
@TestMetadata("parenthesized.kt")
|
||||||
public void testParenthesized() throws Exception {
|
public void testParenthesized() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/senselessComparison/parenthesized.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user