Add a test where a local variable has the same name as a property

This commit is contained in:
pyos
2022-09-28 14:33:12 +02:00
committed by teamcity
parent 03bea0dbaa
commit 77c2601382
7 changed files with 89 additions and 0 deletions
@@ -28850,6 +28850,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOnRefInLambdaInSmartcast.kt");
}
@Test
@TestMetadata("implicitThisOrLocalVar.kt")
public void testImplicitThisOrLocalVar() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOrLocalVar.kt");
}
@Test
@TestMetadata("implicitToGrandSon.kt")
public void testImplicitToGrandSon() throws Exception {
@@ -28850,6 +28850,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOnRefInLambdaInSmartcast.kt");
}
@Test
@TestMetadata("implicitThisOrLocalVar.kt")
public void testImplicitThisOrLocalVar() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOrLocalVar.kt");
}
@Test
@TestMetadata("implicitToGrandSon.kt")
public void testImplicitToGrandSon() throws Exception {
@@ -28850,6 +28850,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOnRefInLambdaInSmartcast.kt");
}
@Test
@TestMetadata("implicitThisOrLocalVar.kt")
public void testImplicitThisOrLocalVar() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOrLocalVar.kt");
}
@Test
@TestMetadata("implicitToGrandSon.kt")
public void testImplicitToGrandSon() throws Exception {
@@ -0,0 +1,26 @@
class Box(var item: String?)
fun <T> take(it: T) {}
fun Box.test() {
val other = Box("")
myRun {
if (item != null) {
take<String>(<!SMARTCAST_IMPOSSIBLE!>item<!>)
other.item = null
take<String>(<!SMARTCAST_IMPOSSIBLE!>item<!>)
this.item = null
take<String>(<!SMARTCAST_IMPOSSIBLE!>item<!>)
}
}
var item: String? = "OK"
myRun {
if (item != null) {
this.item = null
take<String>(<!SMARTCAST_IMPOSSIBLE!>item<!>)
}
}
}
fun myRun(block: () -> Unit) {}
@@ -0,0 +1,26 @@
class Box(var item: String?)
fun <T> take(it: T) {}
fun Box.test() {
val other = Box("")
myRun {
if (item != null) {
take<String>(<!SMARTCAST_IMPOSSIBLE!>item<!>)
other.item = null
take<String>(<!SMARTCAST_IMPOSSIBLE!>item<!>)
this.item = null
take<String>(<!TYPE_MISMATCH!>item<!>)
}
}
var item: String? = "OK"
myRun {
if (item != null) {
this.item = null
take<String>(<!DEBUG_INFO_SMARTCAST!>item<!>)
}
}
}
fun myRun(block: () -> Unit) {}
@@ -0,0 +1,13 @@
package
public fun myRun(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
public fun </*0*/ T> take(/*0*/ it: T): kotlin.Unit
public fun Box.test(): kotlin.Unit
public final class Box {
public constructor Box(/*0*/ item: kotlin.String?)
public final var item: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -28940,6 +28940,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOnRefInLambdaInSmartcast.kt");
}
@Test
@TestMetadata("implicitThisOrLocalVar.kt")
public void testImplicitThisOrLocalVar() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/implicitThisOrLocalVar.kt");
}
@Test
@TestMetadata("implicitToGrandSon.kt")
public void testImplicitToGrandSon() throws Exception {