Add test for KT-54744

This commit is contained in:
pyos
2022-11-01 12:44:28 +01:00
committed by teamcity
parent a926edd845
commit 31eaa211b7
6 changed files with 104 additions and 0 deletions
@@ -30607,6 +30607,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertySubtypeInMemberCheck.kt");
}
@Test
@TestMetadata("reassignedDependency.kt")
public void testReassignedDependency() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/reassignedDependency.kt");
}
@Test
@TestMetadata("varAsUse.kt")
public void testVarAsUse() throws Exception {
@@ -30607,6 +30607,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertySubtypeInMemberCheck.kt");
}
@Test
@TestMetadata("reassignedDependency.kt")
public void testReassignedDependency() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/reassignedDependency.kt");
}
@Test
@TestMetadata("varAsUse.kt")
public void testVarAsUse() throws Exception {
@@ -30607,6 +30607,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertySubtypeInMemberCheck.kt");
}
@Test
@TestMetadata("reassignedDependency.kt")
public void testReassignedDependency() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/reassignedDependency.kt");
}
@Test
@TestMetadata("varAsUse.kt")
public void testVarAsUse() throws Exception {
@@ -0,0 +1,40 @@
// SKIP_TXT
class C(val x: String?)
fun test1() {
var c = C("...")
val x = c.x
if (x == null) return
x.length // ok
c.x.length // ok
c = C(null)
x<!UNSAFE_CALL!>.<!>length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}
fun test2() {
var c = C("...")
val x = c.x
if (x == null) return
while (true) {
x<!UNSAFE_CALL!>.<!>length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
c = C(null)
x<!UNSAFE_CALL!>.<!>length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}
}
fun test3(p: Boolean) {
var c = C("...")
val x = c.x
if (x == null) return
x.length // ok
c.x.length // ok
if (p) {
c = C(null)
}
x.length // ok
c.x.length // bad
}
@@ -0,0 +1,40 @@
// SKIP_TXT
class C(val x: String?)
fun test1() {
var c = C("...")
val x = c.x
if (x == null) return
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // ok
c = C(null)
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}
fun test2() {
var c = C("...")
val x = c.x
if (x == null) return
while (true) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
c = C(null)
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}
}
fun test3(p: Boolean) {
var c = C("...")
val x = c.x
if (x == null) return
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // ok
if (p) {
c = C(null)
}
<!DEBUG_INFO_SMARTCAST!>x<!>.length // ok
c.x<!UNSAFE_CALL!>.<!>length // bad
}
@@ -30697,6 +30697,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertySubtypeInMemberCheck.kt");
}
@Test
@TestMetadata("reassignedDependency.kt")
public void testReassignedDependency() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/variables/reassignedDependency.kt");
}
@Test
@TestMetadata("varAsUse.kt")
public void testVarAsUse() throws Exception {