More correct handling of possible type set during assignment #KT-8229 Fixed
This commit is contained in:
+1
-1
@@ -175,7 +175,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
putNullability(nullability, a, nullabilityOfB);
|
||||
|
||||
SetMultimap<DataFlowValue, KotlinType> newTypeInfo = newTypeInfo();
|
||||
Set<KotlinType> typesForB = collectTypesFromMeAndParents(b);
|
||||
Set<KotlinType> typesForB = getPossibleTypes(b);
|
||||
// Own type of B must be recorded separately, e.g. for a constant
|
||||
// But if its type is the same as A or it's null, there is no reason to do it
|
||||
// because usually null type or own type are not saved in this set
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
fun foo(x: String) = x
|
||||
|
||||
fun test1() {
|
||||
var c: Any? = "XXX"
|
||||
if (c !is String) return
|
||||
|
||||
val newC: String? = "YYY"
|
||||
if (newC != null) {
|
||||
c = newC
|
||||
}
|
||||
foo(<!DEBUG_INFO_SMARTCAST!>c<!>)
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var c: Any? = "XXX"
|
||||
if (c !is String) return
|
||||
|
||||
val newC: String? = "YYY"
|
||||
if (newC is String) {
|
||||
c = newC
|
||||
}
|
||||
foo(<!DEBUG_INFO_SMARTCAST!>c<!>)
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var c: Any? = "XXX"
|
||||
if (c !is String) return
|
||||
|
||||
val newC: String? = "YYY"
|
||||
if (newC == null) return
|
||||
c = newC
|
||||
|
||||
foo(<!DEBUG_INFO_SMARTCAST!>c<!>)
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ x: kotlin.String): kotlin.String
|
||||
public fun test1(): kotlin.Unit
|
||||
public fun test2(): kotlin.Unit
|
||||
public fun test3(): kotlin.Unit
|
||||
@@ -15344,6 +15344,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("assignmentConversion.kt")
|
||||
public void testAssignmentConversion() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/variables/assignmentConversion.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("doWhileWithMiddleBreak.kt")
|
||||
public void testDoWhileWithMiddleBreak() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/variables/doWhileWithMiddleBreak.kt");
|
||||
|
||||
Reference in New Issue
Block a user