Add test on data-flow
Idea is to intersect similar smartcasts on similar properties coming from *different* instances (something like 'this.x == null && other.x == null' ). It checks that we distinguish subjects of such smartcasts properly. Currently behavior is undesired, see KT-27260
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||||
|
// See KT-27260
|
||||||
|
|
||||||
|
class A(val x: String?) {
|
||||||
|
fun foo(other: A) {
|
||||||
|
when {
|
||||||
|
x == null && other.x == null -> "1"
|
||||||
|
<!DEBUG_INFO_SMARTCAST!>x<!>.length > 0 -> "2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public final class A {
|
||||||
|
public constructor A(/*0*/ x: kotlin.String?)
|
||||||
|
public final val x: kotlin.String?
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(/*0*/ other: A): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -19377,6 +19377,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("smartcastOnSameFieldOfDifferentInstances.kt")
|
||||||
|
public void testSmartcastOnSameFieldOfDifferentInstances() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastOnSameFieldOfDifferentInstances.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("thisWithLabel.kt")
|
@TestMetadata("thisWithLabel.kt")
|
||||||
public void testThisWithLabel() throws Exception {
|
public void testThisWithLabel() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt");
|
||||||
|
|||||||
Generated
+5
@@ -19377,6 +19377,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("smartcastOnSameFieldOfDifferentInstances.kt")
|
||||||
|
public void testSmartcastOnSameFieldOfDifferentInstances() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastOnSameFieldOfDifferentInstances.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("thisWithLabel.kt")
|
@TestMetadata("thisWithLabel.kt")
|
||||||
public void testThisWithLabel() throws Exception {
|
public void testThisWithLabel() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt");
|
runTest("compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user