[FIR] Ensure this@label doesn't work in K2

This commit is contained in:
Nikolay Lunyak
2023-03-07 13:08:22 +02:00
committed by Space Team
parent 62d2327ca3
commit 409249267c
6 changed files with 106 additions and 0 deletions
@@ -525,6 +525,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/kt56769.kt");
}
@Test
@TestMetadata("kt56877.kt")
public void testKt56877() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt56877.kt");
}
@Test
@TestMetadata("kt57085.kt")
public void testKt57085() throws Exception {
@@ -525,6 +525,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/kt56769.kt");
}
@Test
@TestMetadata("kt56877.kt")
public void testKt56877() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt56877.kt");
}
@Test
@TestMetadata("kt57085.kt")
public void testKt57085() throws Exception {
@@ -525,6 +525,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/kt56769.kt");
}
@Test
@TestMetadata("kt56877.kt")
public void testKt56877() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt56877.kt");
}
@Test
@TestMetadata("kt57085.kt")
public void testKt57085() throws Exception {
+41
View File
@@ -0,0 +1,41 @@
@file:OptIn(ExperimentalContracts::class)
import kotlin.contracts.*
class Success : Result()
open class Result {
val someProperty = run { 10 }
fun isSuccess1(): Boolean {
contract {
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (this<!UNRESOLVED_LABEL!>@Result<!> is Success)<!>
}
return this@Result is Success
}
fun isSuccess2(): Boolean {
contract {
// implicit type ref
// ERROR CLASS: Cannot calculate return type during full-body resolution (local class/object?)
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (this<!UNRESOLVED_LABEL!>@Result<!>.someProperty == 10)<!>
}
return this@Result.someProperty == 10
}
}
fun Result.isSuccess3(): Boolean {
contract {
returns(true) implies (this@isSuccess3 is Success)
}
return this@isSuccess3 is Success
}
fun Result.isSuccess4(): Boolean {
contract {
// implicit type ref
// ERROR CLASS: Cannot calculate return type during full-body resolution (local class/object?)
<!ERROR_IN_CONTRACT_DESCRIPTION!>returns(true) implies (this@isSuccess4.someProperty == 10)<!>
}
return this@isSuccess4.someProperty == 10
}
+41
View File
@@ -0,0 +1,41 @@
@file:OptIn(ExperimentalContracts::class)
import kotlin.contracts.*
class Success : Result()
open class Result {
val someProperty = run { 10 }
fun isSuccess1(): Boolean {
contract {
returns(true) implies (this@Result is Success)
}
return this@Result is Success
}
fun isSuccess2(): Boolean {
contract {
// implicit type ref
// ERROR CLASS: Cannot calculate return type during full-body resolution (local class/object?)
returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>this@Result.someProperty<!> == 10)
}
return this@Result.someProperty == 10
}
}
fun Result.isSuccess3(): Boolean {
contract {
returns(true) implies (this@isSuccess3 is Success)
}
return this@isSuccess3 is Success
}
fun Result.isSuccess4(): Boolean {
contract {
// implicit type ref
// ERROR CLASS: Cannot calculate return type during full-body resolution (local class/object?)
returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION!>this@isSuccess4.someProperty<!> == 10)
}
return this@isSuccess4.someProperty == 10
}
@@ -525,6 +525,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/kt56769.kt");
}
@Test
@TestMetadata("kt56877.kt")
public void testKt56877() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt56877.kt");
}
@Test
@TestMetadata("kt57085.kt")
public void testKt57085() throws Exception {