Test for KT-14381 and KT-13597
This commit is contained in:
committed by
Mikhail Glukhikh
parent
fbc1d1a844
commit
8fa739ed0f
+48
@@ -0,0 +1,48 @@
|
|||||||
|
// Tests for KT-13597 (val assignment inside local object in constructor)
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
val a: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
val t = object {
|
||||||
|
fun some() {
|
||||||
|
// See KT-13597
|
||||||
|
a = "12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a = "2"
|
||||||
|
t.some()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test2 {
|
||||||
|
init {
|
||||||
|
val t = object {
|
||||||
|
fun some() {
|
||||||
|
<!VAL_REASSIGNMENT!>a<!> = "12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<!INITIALIZATION_BEFORE_DECLARATION!>a<!> = "2"
|
||||||
|
t.some()
|
||||||
|
}
|
||||||
|
|
||||||
|
val a: String
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests for KT-14381 (val assignment inside lambda in constructor)
|
||||||
|
|
||||||
|
fun <T> exec(f: () -> T): T = f()
|
||||||
|
|
||||||
|
class Test4 {
|
||||||
|
val a: String
|
||||||
|
|
||||||
|
init {
|
||||||
|
exec {
|
||||||
|
// See KT-14381
|
||||||
|
a = "12"
|
||||||
|
}
|
||||||
|
a = "34"
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ T> exec(/*0*/ f: () -> T): T
|
||||||
|
|
||||||
|
public final class Test {
|
||||||
|
public constructor Test()
|
||||||
|
public final val a: 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
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Test2 {
|
||||||
|
public constructor Test2()
|
||||||
|
public final val a: 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
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Test4 {
|
||||||
|
public constructor Test4()
|
||||||
|
public final val a: 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
|
||||||
|
}
|
||||||
@@ -3670,6 +3670,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("assignmentInLocalsInConstructor.kt")
|
||||||
|
public void testAssignmentInLocalsInConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis/assignmentInLocalsInConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("backingFieldInsideGetter.kt")
|
@TestMetadata("backingFieldInsideGetter.kt")
|
||||||
public void testBackingFieldInsideGetter() throws Exception {
|
public void testBackingFieldInsideGetter() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user