FIR: Fix test data after making LHS of assignment an expression

KT-54648
This commit is contained in:
Kirill Rakhman
2023-01-16 09:55:03 +01:00
committed by Space Team
parent ace47c06a5
commit 1eb18f13bd
68 changed files with 372 additions and 117 deletions
@@ -1,3 +1,3 @@
KtErrorCallInfo: KtErrorCallInfo:
candidateCalls = [] candidateCalls = []
diagnostic = ERROR<VARIABLE_EXPECTED: Variable expected> diagnostic = ERROR<UNRESOLVED_REFERENCE: Unresolved reference: get>
@@ -1,6 +1,6 @@
KT element: KtNameReferenceExpression KT element: KtNameReferenceExpression
FIR element: FirResolvedNamedReferenceImpl FIR element: FirVariableAssignmentImpl
FIR source kind: ReferenceInAtomicQualifiedAccess FIR source kind: KtRealSourceElementKind
FIR element rendered: FIR element rendered:
R|<local>/i| R|<local>/i| = R|<local>/i|.R|kotlin/Int.plus|(Int(1))
@@ -73,7 +73,7 @@ FILE: anonymousObjectInInvalidPosition.kt
CONTRACTS: CONTRACTS:
FILE: anonymousObjectInInvalidPosition.kt FILE: anonymousObjectInInvalidPosition.kt
private final [CONTRACTS] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)<Unsupported LValue: NULL># = object : A<Int> { private final [CONTRACTS] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)Null(null) = object : A<Int> {
private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| { private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<<implicit>>() super<<implicit>>()
} }
@@ -91,7 +91,7 @@ FILE: anonymousObjectInInvalidPosition.kt
IMPLICIT_TYPES_BODY_RESOLVE: IMPLICIT_TYPES_BODY_RESOLVE:
FILE: anonymousObjectInInvalidPosition.kt FILE: anonymousObjectInInvalidPosition.kt
private final [IMPLICIT_TYPES_BODY_RESOLVE] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)<Unsupported LValue: NULL># = object : A<Int> { private final [IMPLICIT_TYPES_BODY_RESOLVE] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)Null(null) = object : A<Int> {
private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| { private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<<implicit>>() super<<implicit>>()
} }
@@ -109,7 +109,7 @@ FILE: anonymousObjectInInvalidPosition.kt
ANNOTATIONS_ARGUMENTS_MAPPING: ANNOTATIONS_ARGUMENTS_MAPPING:
FILE: anonymousObjectInInvalidPosition.kt FILE: anonymousObjectInInvalidPosition.kt
private final [ANNOTATIONS_ARGUMENTS_MAPPING] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)<Unsupported LValue: NULL># = object : A<Int> { private final [ANNOTATIONS_ARGUMENTS_MAPPING] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)Null(null) = object : A<Int> {
private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| { private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<<implicit>>() super<<implicit>>()
} }
@@ -127,7 +127,7 @@ FILE: anonymousObjectInInvalidPosition.kt
EXPECT_ACTUAL_MATCHING: EXPECT_ACTUAL_MATCHING:
FILE: anonymousObjectInInvalidPosition.kt FILE: anonymousObjectInInvalidPosition.kt
private final [EXPECT_ACTUAL_MATCHING] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)<Unsupported LValue: NULL># = object : A<Int> { private final [EXPECT_ACTUAL_MATCHING] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)Null(null) = object : A<Int> {
private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| { private [RAW_FIR] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<<implicit>>() super<<implicit>>()
} }
@@ -145,7 +145,7 @@ FILE: anonymousObjectInInvalidPosition.kt
BODY_RESOLVE: BODY_RESOLVE:
FILE: anonymousObjectInInvalidPosition.kt FILE: anonymousObjectInInvalidPosition.kt
private final [BODY_RESOLVE] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)<Unsupported LValue: NULL># = object : R|A<kotlin/Int>| { private final [BODY_RESOLVE] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)Null(null) = object : R|A<kotlin/Int>| {
private [BODY_RESOLVE] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| { private [BODY_RESOLVE] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
@@ -163,7 +163,7 @@ FILE: anonymousObjectInInvalidPosition.kt
FILE RAW TO BODY: FILE RAW TO BODY:
FILE: anonymousObjectInInvalidPosition.kt FILE: anonymousObjectInInvalidPosition.kt
private final [BODY_RESOLVE] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)<Unsupported LValue: NULL># = object : R|A<kotlin/Int>| { private final [BODY_RESOLVE] val resolveMe: <ERROR TYPE REF: Wrong number of type arguments> = ERROR_EXPR(Should have initializer)Null(null) = object : R|A<kotlin/Int>| {
private [BODY_RESOLVE] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| { private [BODY_RESOLVE] [ContainingClassKey=<anonymous>] constructor(): R|<anonymous>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
@@ -4630,6 +4630,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/arrayInLocal.kt"); runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/arrayInLocal.kt");
} }
@Test
@TestMetadata("assignmentWithWrongLhs.kt")
public void testAssignmentWithWrongLhs() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/assignmentWithWrongLhs.kt");
}
@Test @Test
@TestMetadata("backingField.kt") @TestMetadata("backingField.kt")
public void testBackingField() throws Exception { public void testBackingField() throws Exception {
@@ -4168,6 +4168,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt"); runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt");
} }
@Test
@TestMetadata("AsInCompoundAssignment.kt")
public void testAsInCompoundAssignment() throws Exception {
runTest("compiler/testData/diagnostics/tests/cast/AsInCompoundAssignment.kt");
}
@Test @Test
@TestMetadata("AsInExpressionBody.kt") @TestMetadata("AsInExpressionBody.kt")
public void testAsInExpressionBody() throws Exception { public void testAsInExpressionBody() throws Exception {
@@ -6,6 +6,6 @@ FILE: fieldPlusAssign.kt
} }
public final val y: R|kotlin/Int| = Int(1) public final val y: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int| { public get(): R|kotlin/Int| {
<Re-assigning a val variable># = F|/y|.R|kotlin/Int.plus|(Int(1)) F|/y| = F|/y|.R|kotlin/Int.plus|(Int(1))
^ Int(1) ^ Int(1)
} }
@@ -14,7 +14,7 @@ class Some {
<!VAL_REASSIGNMENT!>z<!> = "error" <!VAL_REASSIGNMENT!>z<!> = "error"
fun foo() { fun foo() {
<!CAPTURED_MEMBER_VAL_INITIALIZATION!>x<!> = "error" // VAL_REASSIGNMENT also ok (or even better?) <!VAL_REASSIGNMENT!>x<!> = "error"
<!CAPTURED_MEMBER_VAL_INITIALIZATION!>y<!> = "error" <!CAPTURED_MEMBER_VAL_INITIALIZATION!>y<!> = "error"
<!VAL_REASSIGNMENT!>z<!> = "error" <!VAL_REASSIGNMENT!>z<!> = "error"
} }
@@ -73,5 +73,5 @@ class B5 : A5() {
} }
fun test5() { fun test5() {
<!INVISIBLE_SETTER!>B5().attribute<!> = "c" B5().<!INVISIBLE_SETTER!>attribute<!> = "c"
} }
+2 -2
View File
@@ -2,7 +2,7 @@ fun <T> bar(): T {
return null <!UNCHECKED_CAST!>as T<!> return null <!UNCHECKED_CAST!>as T<!>
} }
class X() : <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>B<!> by <!ASSIGNMENT_IN_EXPRESSION_CONTEXT!><!VARIABLE_EXPECTED!>get()<!> = bar()<!> { class X() : <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>B<!> by <!ASSIGNMENT_IN_EXPRESSION_CONTEXT!><!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = bar()<!> {
val prop = <!ASSIGNMENT_IN_EXPRESSION_CONTEXT!><!VARIABLE_EXPECTED!>bar()<!> = 2<!> val prop = <!ASSIGNMENT_IN_EXPRESSION_CONTEXT!><!VARIABLE_EXPECTED!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!>()<!> = 2<!>
} }
@@ -0,0 +1,24 @@
FILE: assignmentWithWrongLhs.kt
public final fun foo(): R|kotlin/Int| {
^foo Int(1)
}
public final fun test(): R|kotlin/Unit| {
R|/foo|() = Int(1)
R|/foo|().R|kotlin/Int.toString|() = Int(1)
when () {
Boolean(true) -> {
R|/foo|()
}
else -> {
Int(1)
}
}
= String()
R|kotlin/run|<R|kotlin/Unit|>(<L> = run@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
R|kotlin/io/print|(String(To string)).R|kotlin/also|<R|kotlin/Unit|>(<L> = also@fun <anonymous>(it: R|kotlin/Unit|): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
R|kotlin/io/print|(R|<local>/it|)
}
)
}
) = Int(1)
}
@@ -0,0 +1,10 @@
fun foo(): Int = 1
fun test() {
<!VARIABLE_EXPECTED!>foo()<!> = 1
foo().<!VARIABLE_EXPECTED!>toString()<!> = <!ASSIGNMENT_TYPE_MISMATCH!>1<!>
(<!VARIABLE_EXPECTED!>if (true) foo() else 1<!>) = <!ASSIGNMENT_TYPE_MISMATCH!>""<!>
<!VARIABLE_EXPECTED!>run {
print("To string").also { print(it) }
}<!> = <!ASSIGNMENT_TYPE_MISMATCH!>1<!>
}
@@ -18,5 +18,5 @@ FILE: hashSet.kt
public final fun foo(): R|kotlin/Unit| { public final fun foo(): R|kotlin/Unit| {
lvar c: R|kotlin/collections/MutableSet<kotlin/String>?| = Null(null) lvar c: R|kotlin/collections/MutableSet<kotlin/String>?| = Null(null)
R|<local>/c| = R|java/util/HashSet.HashSet|<R|kotlin/String|>() R|<local>/c| = R|java/util/HashSet.HashSet|<R|kotlin/String|>()
R|<local>/c|!!.R|/d| = R|/produce|<R|kotlin/String?|>() R|<local>/c|!!.R|/d|<R|kotlin/String|> = R|/produce|<R|kotlin/String?|>()
} }
@@ -1,10 +1,10 @@
FILE: listPlusAssign.kt FILE: listPlusAssign.kt
public final fun R|kotlin/collections/List<kotlin/String>|.modify(): R|kotlin/Unit| { public final fun R|kotlin/collections/List<kotlin/String>|.modify(): R|kotlin/Unit| {
<Variable expected># = this@R|/modify|.R|kotlin/collections/plus|<R|kotlin/String|>(String(Alpha)) this@R|/modify| = this@R|/modify|.R|kotlin/collections/plus|<R|kotlin/String|>(String(Alpha))
<Variable expected># = this@R|/modify|.R|kotlin/collections/plus|<R|kotlin/String|>(String(Omega)) this@R|/modify| = this@R|/modify|.R|kotlin/collections/plus|<R|kotlin/String|>(String(Omega))
} }
public final fun R|kotlin/Any|.modify(): R|kotlin/Unit| { public final fun R|kotlin/Any|.modify(): R|kotlin/Unit| {
<Variable expected># = (this@R|/modify| as R|kotlin/collections/List<kotlin/Int>|).R|kotlin/collections/plus|<R|kotlin/Int|>(Int(42)) (this@R|/modify| as R|kotlin/collections/List<kotlin/Int>|) = (this@R|/modify| as R|kotlin/collections/List<kotlin/Int>|).R|kotlin/collections/plus|<R|kotlin/Int|>(Int(42))
} }
public final operator fun <T> R|kotlin/collections/Set<T>|.plusAssign(x: R|T|): R|kotlin/Unit| { public final operator fun <T> R|kotlin/collections/Set<T>|.plusAssign(x: R|T|): R|kotlin/Unit| {
} }
@@ -1,8 +1,8 @@
// COMPARE_WITH_LIGHT_TREE // COMPARE_WITH_LIGHT_TREE
fun List<String>.modify() { fun List<String>.modify() {
<!VARIABLE_EXPECTED{PSI}!>this<!> += "Alpha" <!VARIABLE_EXPECTED!>this<!> += "Alpha"
<!VARIABLE_EXPECTED{PSI}!>this<!> += "Omega" <!VARIABLE_EXPECTED!>this<!> += "Omega"
} }
fun Any.modify() { fun Any.modify() {
@@ -4630,6 +4630,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/arrayInLocal.kt"); runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/arrayInLocal.kt");
} }
@Test
@TestMetadata("assignmentWithWrongLhs.kt")
public void testAssignmentWithWrongLhs() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/assignmentWithWrongLhs.kt");
}
@Test @Test
@TestMetadata("backingField.kt") @TestMetadata("backingField.kt")
public void testBackingField() throws Exception { public void testBackingField() throws Exception {
@@ -4630,6 +4630,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/arrayInLocal.kt"); runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/arrayInLocal.kt");
} }
@Test
@TestMetadata("assignmentWithWrongLhs.kt")
public void testAssignmentWithWrongLhs() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/assignmentWithWrongLhs.kt");
}
@Test @Test
@TestMetadata("backingField.kt") @TestMetadata("backingField.kt")
public void testBackingField() throws Exception { public void testBackingField() throws Exception {
@@ -4174,6 +4174,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt"); runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt");
} }
@Test
@TestMetadata("AsInCompoundAssignment.kt")
public void testAsInCompoundAssignment() throws Exception {
runTest("compiler/testData/diagnostics/tests/cast/AsInCompoundAssignment.kt");
}
@Test @Test
@TestMetadata("AsInExpressionBody.kt") @TestMetadata("AsInExpressionBody.kt")
public void testAsInExpressionBody() throws Exception { public void testAsInExpressionBody() throws Exception {
@@ -4168,6 +4168,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt"); runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt");
} }
@Test
@TestMetadata("AsInCompoundAssignment.kt")
public void testAsInCompoundAssignment() throws Exception {
runTest("compiler/testData/diagnostics/tests/cast/AsInCompoundAssignment.kt");
}
@Test @Test
@TestMetadata("AsInExpressionBody.kt") @TestMetadata("AsInExpressionBody.kt")
public void testAsInExpressionBody() throws Exception { public void testAsInExpressionBody() throws Exception {
@@ -9,5 +9,5 @@ FILE: safeCallsWithAssignment.kt
a#?.{ $subj$.b#.get#(IntegerLiteral(0)).set#(IntegerLiteral(0), IntegerLiteral(1)) } a#?.{ $subj$.b#.get#(IntegerLiteral(0)).set#(IntegerLiteral(0), IntegerLiteral(1)) }
a#?.{ $subj$.b# }?.{ $subj$.c#.get#(IntegerLiteral(0)).set#(IntegerLiteral(0), IntegerLiteral(1)) } a#?.{ $subj$.b# }?.{ $subj$.c#.get#(IntegerLiteral(0)).set#(IntegerLiteral(0), IntegerLiteral(1)) }
a#?.{ $subj$.b# }.c#.get#(IntegerLiteral(0)).set#(IntegerLiteral(0), IntegerLiteral(1)) a#?.{ $subj$.b# }.c#.get#(IntegerLiteral(0)).set#(IntegerLiteral(0), IntegerLiteral(1))
a#?.{ $subj$.b# }.d# = IntegerLiteral(1) a#?.{ $subj$.b# }.d#() = IntegerLiteral(1)
} }
@@ -62,7 +62,7 @@ FILE: safeCallsWithUnaryOperators.kt
R|<local>/<unary>| R|<local>/<unary>|
lval <receiver>: <implicit> = a#?.{ $subj$.b# } lval <receiver>: <implicit> = a#?.{ $subj$.b# }
lval <unary>: <implicit> = R|<local>/<receiver>|.d#() lval <unary>: <implicit> = R|<local>/<receiver>|.d#()
R|<local>/<receiver>|.d# = R|<local>/<unary>|.inc#() R|<local>/<receiver>|.d#() = R|<local>/<unary>|.inc#()
R|<local>/<unary>| R|<local>/<unary>|
} }
public? final? fun foo2(): R|kotlin/Unit| { public? final? fun foo2(): R|kotlin/Unit| {
@@ -128,6 +128,6 @@ FILE: safeCallsWithUnaryOperators.kt
R|<local>/<unary-result>| R|<local>/<unary-result>|
lval <receiver>: <implicit> = a#?.{ $subj$.b# } lval <receiver>: <implicit> = a#?.{ $subj$.b# }
lval <unary-result>: <implicit> = R|<local>/<receiver>|.d#().inc#() lval <unary-result>: <implicit> = R|<local>/<receiver>|.d#().inc#()
R|<local>/<receiver>|.d# = R|<local>/<unary-result>| R|<local>/<receiver>|.d#() = R|<local>/<unary-result>|
R|<local>/<unary-result>| R|<local>/<unary-result>|
} }
+6
View File
@@ -5,4 +5,10 @@ compiler/testData/cli/jvm/firLightTree.kt:2:5: error: variable expected
compiler/testData/cli/jvm/firLightTree.kt:3:15: error: classifier 'class System : Any' does not have a companion object, and thus must be initialized here compiler/testData/cli/jvm/firLightTree.kt:3:15: error: classifier 'class System : Any' does not have a companion object, and thus must be initialized here
java.lang.System = null java.lang.System = null
^ ^
compiler/testData/cli/jvm/firLightTree.kt:3:15: error: variable expected
java.lang.System = null
^
compiler/testData/cli/jvm/firLightTree.kt:3:24: error: null can not be a value of a non-null type
java.lang.System = null
^
COMPILATION_ERROR COMPILATION_ERROR
+11 -2
View File
@@ -1,5 +1,14 @@
warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features
compiler/testData/cli/jvm/firLightTree.kt:3:5: error: classifier 'class System : Any' does not have a companion object, and thus must be initialized here compiler/testData/cli/jvm/firLightTree.kt:2:5: error: variable expected
java.lang.System = null this += "Alpha"
^ ^
compiler/testData/cli/jvm/firLightTree.kt:3:15: error: classifier 'class System : Any' does not have a companion object, and thus must be initialized here
java.lang.System = null
^
compiler/testData/cli/jvm/firLightTree.kt:3:15: error: variable expected
java.lang.System = null
^
compiler/testData/cli/jvm/firLightTree.kt:3:24: error: null can not be a value of a non-null type
java.lang.System = null
^
COMPILATION_ERROR COMPILATION_ERROR
@@ -45,8 +45,8 @@ fun cannotBe() {
<!VARIABLE_EXPECTED!>""<!> = ""; <!VARIABLE_EXPECTED!>""<!> = "";
<!VARIABLE_EXPECTED!>foo()<!> = Unit; <!VARIABLE_EXPECTED!>foo()<!> = Unit;
(<!VARIABLE_EXPECTED!>i as Int<!>) = 34 (<!VARIABLE_EXPECTED!>i <!USELESS_CAST!>as Int<!><!>) = 34
(<!VARIABLE_EXPECTED!>i is Int<!>) = false (<!USELESS_IS_CHECK, VARIABLE_EXPECTED!>i is Int<!>) = false
<!VARIABLE_EXPECTED!>A()<!> = A() <!VARIABLE_EXPECTED!>A()<!> = A()
<!VARIABLE_EXPECTED!>5<!> = 34 <!VARIABLE_EXPECTED!>5<!> = 34
} }
@@ -0,0 +1,29 @@
public interface ITest {
public var prop : Int
get() = 12
set(value) {}
}
abstract class ATest {
protected open var prop2 : Int
get() = 13
set(value) {}
}
class Test: ATest(), ITest {
override var prop : Int
get() = 12
<!CANNOT_WEAKEN_ACCESS_PRIVILEGE!>private<!> set(value) {}
override var prop2 : Int
get() = 14
<!CANNOT_CHANGE_ACCESS_PRIVILEGE, SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY!>internal<!> set(value) {}
}
fun main() {
val test = Test()
test.<!INVISIBLE_SETTER!>prop<!> = 12
val itest: ITest = test
itest.prop = 12 // No error here
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
public interface ITest { public interface ITest {
public var prop : Int public var prop : Int
get() = 12 get() = 12
@@ -14,10 +14,10 @@ val xssss = <!EXPRESSION_EXPECTED_PACKAGE_FOUND!>foo<!>
val f = { <!NO_COMPANION_OBJECT!>System<!> } val f = { <!NO_COMPANION_OBJECT!>System<!> }
fun main() { fun main() {
<!EXPRESSION_EXPECTED_PACKAGE_FOUND!>java<!> = null <!EXPRESSION_EXPECTED_PACKAGE_FOUND, VARIABLE_EXPECTED!>java<!> = <!NULL_FOR_NONNULL_TYPE!>null<!>
<!NO_COMPANION_OBJECT!>System<!> = null <!NO_COMPANION_OBJECT, VARIABLE_EXPECTED!>System<!> = <!NULL_FOR_NONNULL_TYPE!>null<!>
<!NO_COMPANION_OBJECT!>System<!>!! <!NO_COMPANION_OBJECT!>System<!>!!
<!NO_COMPANION_OBJECT{LT}!>java.lang.<!NO_COMPANION_OBJECT{PSI}!>System<!><!> = null java.lang.<!NO_COMPANION_OBJECT, VARIABLE_EXPECTED!>System<!> = <!NULL_FOR_NONNULL_TYPE!>null<!>
java.lang.<!NO_COMPANION_OBJECT!>System<!>!! java.lang.<!NO_COMPANION_OBJECT!>System<!>!!
<!NO_COMPANION_OBJECT!>System<!> is Int <!NO_COMPANION_OBJECT!>System<!> is Int
<!INVISIBLE_REFERENCE!>System<!>() <!INVISIBLE_REFERENCE!>System<!>()
@@ -9,6 +9,6 @@ class Foo {
fun main() { fun main() {
val f = Foo() val f = Foo()
val a: Int val a: Int
<!VARIABLE_EXPECTED!>get()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>) <!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
} }
@@ -9,6 +9,6 @@ class Foo {
fun main(x: Int) { fun main(x: Int) {
val f = Foo() val f = Foo()
val a: Int val a: Int
<!VARIABLE_EXPECTED!>get()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>) <!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
} }
@@ -0,0 +1,8 @@
// FIR_IDENTICAL
class A {
var b = 1
}
fun Any.test() {
(this as A).b += 1 <!USELESS_CAST!>as Int<!>
}
@@ -0,0 +1,11 @@
package
public fun kotlin.Any.test(): kotlin.Unit
public final class A {
public constructor A()
public final var b: kotlin.Int
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
}
@@ -104,6 +104,21 @@ fun t5() {
} }
} }
fun t6() {
val i = 0
fun t5() {
<!VAL_REASSIGNMENT!>i<!> += 3
}
}
fun t7() {
for (i in 0..2) {
fun t5() {
<!VAL_REASSIGNMENT!>i<!> = 3
}
}
}
// ------------------------------------------------ // ------------------------------------------------
// backing fields // backing fields
@@ -104,6 +104,21 @@ fun t5() {
} }
} }
fun t6() {
val i = 0
fun t5() {
<!VAL_REASSIGNMENT!>i<!> += 3
}
}
fun t7() {
for (i in 0..2) {
fun t5() {
<!VAL_REASSIGNMENT!>i<!> = 3
}
}
}
// ------------------------------------------------ // ------------------------------------------------
// backing fields // backing fields
@@ -16,6 +16,8 @@ package uninitialized_reassigned_variables {
public fun t4(): kotlin.Unit public fun t4(): kotlin.Unit
public fun t4(/*0*/ a: uninitialized_reassigned_variables.A): kotlin.Unit public fun t4(/*0*/ a: uninitialized_reassigned_variables.A): kotlin.Unit
public fun t5(): kotlin.Unit public fun t5(): kotlin.Unit
public fun t6(): kotlin.Unit
public fun t7(): kotlin.Unit
public fun test(/*0*/ m: uninitialized_reassigned_variables.M): kotlin.Unit public fun test(/*0*/ m: uninitialized_reassigned_variables.M): kotlin.Unit
public fun test1(/*0*/ m: uninitialized_reassigned_variables.M): kotlin.Unit public fun test1(/*0*/ m: uninitialized_reassigned_variables.M): kotlin.Unit
@@ -23,23 +23,23 @@ class P {
fun foo() { fun foo() {
val p = P() val p = P()
<!INVISIBLE_SETTER!>p.x<!> = 34 //should be an error here p.<!INVISIBLE_SETTER!>x<!> = 34 //should be an error here
p.y = 23 p.y = 23
fun inner() { fun inner() {
<!INVISIBLE_SETTER!>p.x<!> = 44 p.<!INVISIBLE_SETTER!>x<!> = 44
} }
} }
class R { class R {
val p = P(); val p = P();
init { init {
<!INVISIBLE_SETTER!>p.x<!> = 42 p.<!INVISIBLE_SETTER!>x<!> = 42
} }
val testInGetterInOtherClass : Int val testInGetterInOtherClass : Int
get() { get() {
<!INVISIBLE_SETTER!>p.x<!> = 33 p.<!INVISIBLE_SETTER!>x<!> = 33
return 3 return 3
} }
} }
@@ -0,0 +1,36 @@
//KT-2960 Perform control flow checks for package property initializers
package b
class P {
var x : Int = 0
private set
}
val p = P()
var f = { -> p.<!INVISIBLE_SETTER!>x<!> = 32 }
val o = object {
fun run() {
p.<!INVISIBLE_SETTER!>x<!> = 4
val z : Int
doSmth(<!UNINITIALIZED_VARIABLE!>z<!>)
}
}
val g = { ->
val x: Int
doSmth(<!UNINITIALIZED_VARIABLE!>x<!>)
}
class A {
val a : Int = 1
get() {
val x : Int
doSmth(<!UNINITIALIZED_VARIABLE!>x<!>)
return field
}
}
fun doSmth(i: Int) = i
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
//KT-2960 Perform control flow checks for package property initializers //KT-2960 Perform control flow checks for package property initializers
package b package b
@@ -0,0 +1,30 @@
// !DIAGNOSTICS: -UNREACHABLE_CODE -UNUSED_PARAMETER
// !CHECK_TYPE
// t is unused due to KT-4233
// FILE: test.kt
interface Tr<T> {
var v: T
}
fun test(t: Tr<*>) {
t.v = null!!
t.v = <!ASSIGNMENT_TYPE_MISMATCH!>""<!>
t.v = <!NULL_FOR_NONNULL_TYPE!>null<!>
t.v checkType { _<Any?>() }
}
fun test2(t: JavaClass<*>) {
t.v = null!!
t.v = <!ASSIGNMENT_TYPE_MISMATCH!>""<!>
t.v = null
t.v checkType { _<Any?>() }
}
// FILE: JavaClass.java
public interface JavaClass<T> {
public T getV();
public void setV(T v);
}
@@ -1,7 +1,9 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNREACHABLE_CODE -UNUSED_PARAMETER // !DIAGNOSTICS: -UNREACHABLE_CODE -UNUSED_PARAMETER
// !CHECK_TYPE // !CHECK_TYPE
// t is unused due to KT-4233 // t is unused due to KT-4233
// FILE: test.kt
interface Tr<T> { interface Tr<T> {
var v: T var v: T
} }
@@ -12,3 +14,17 @@ fun test(t: Tr<*>) {
<!SETTER_PROJECTED_OUT!>t.v<!> = null <!SETTER_PROJECTED_OUT!>t.v<!> = null
t.v checkType { _<Any?>() } t.v checkType { _<Any?>() }
} }
fun test2(t: JavaClass<*>) {
t.v = null!!
t.v = ""
t.v = null
t.v checkType { _<Any?>() }
}
// FILE: JavaClass.java
public interface JavaClass<T> {
public T getV();
public void setV(T v);
}
@@ -1,6 +1,15 @@
package package
public fun test(/*0*/ t: Tr<*>): kotlin.Unit public fun test(/*0*/ t: Tr<*>): kotlin.Unit
public fun test2(/*0*/ t: JavaClass<*>): kotlin.Unit
public interface JavaClass</*0*/ T : kotlin.Any!> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun getV(): T!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun setV(/*0*/ v: T!): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface Tr</*0*/ T> { public interface Tr</*0*/ T> {
public abstract var v: T public abstract var v: T
@@ -0,0 +1,10 @@
// !DIAGNOSTICS: -UNREACHABLE_CODE
interface Tr<T> {
var v: T
}
fun test(t: Tr<out String>) {
// resolved as t.v = t.v + null!!, where type of right operand is String,
// so TYPE_MISMATCH: String is not <: of Captured(out String)
<!ASSIGNMENT_TYPE_MISMATCH!>t.v += null!!<!>
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNREACHABLE_CODE // !DIAGNOSTICS: -UNREACHABLE_CODE
interface Tr<T> { interface Tr<T> {
var v: T var v: T
@@ -43,7 +43,7 @@ public class Bar<T> {
} }
fun takeStarBar(x: Bar<*>) { fun takeStarBar(x: Bar<*>) {
<!SETTER_PROJECTED_OUT!>x.value<!> = "test" x.value = <!ASSIGNMENT_TYPE_MISMATCH!>"test"<!>
x.value <!UNRESOLVED_REFERENCE!>+=<!> "test" x.value <!UNRESOLVED_REFERENCE!>+=<!> "test"
} }
@@ -74,7 +74,7 @@ public class Bar2<T> {
} }
fun takeStarBar2(x: Bar2<*>) { fun takeStarBar2(x: Bar2<*>) {
<!SETTER_PROJECTED_OUT!>x.value<!> = "test" x.value = <!ASSIGNMENT_TYPE_MISMATCH!>"test"<!>
x.value <!UNRESOLVED_REFERENCE!>+=<!> "test" x.value <!UNRESOLVED_REFERENCE!>+=<!> "test"
} }
@@ -106,7 +106,7 @@ class Bar3<T> {
} }
fun takeStarBar3(x: Bar3<*>) { fun takeStarBar3(x: Bar3<*>) {
<!SETTER_PROJECTED_OUT!>x.value<!> = "test" x.value = <!ASSIGNMENT_TYPE_MISMATCH!>"test"<!>
x.value <!UNRESOLVED_REFERENCE!>+=<!> "test" x.value <!UNRESOLVED_REFERENCE!>+=<!> "test"
} }
@@ -43,7 +43,7 @@ public class Bar<T> {
} }
fun takeStarBar(x: Bar<*>) { fun takeStarBar(x: Bar<*>) {
<!SETTER_PROJECTED_OUT!>x.value<!> = "test" x.value = <!ASSIGNMENT_TYPE_MISMATCH!>"test"<!>
x.value <!UNRESOLVED_REFERENCE!>+=<!> "test" x.value <!UNRESOLVED_REFERENCE!>+=<!> "test"
} }
@@ -74,7 +74,7 @@ public class Bar2<T> {
} }
fun takeStarBar2(x: Bar2<*>) { fun takeStarBar2(x: Bar2<*>) {
<!SETTER_PROJECTED_OUT!>x.value<!> = "test" x.value = <!ASSIGNMENT_TYPE_MISMATCH!>"test"<!>
x.value <!UNRESOLVED_REFERENCE!>+=<!> "test" x.value <!UNRESOLVED_REFERENCE!>+=<!> "test"
} }
@@ -106,7 +106,7 @@ class Bar3<T> {
} }
fun takeStarBar3(x: Bar3<*>) { fun takeStarBar3(x: Bar3<*>) {
<!SETTER_PROJECTED_OUT!>x.value<!> = "test" x.value = <!ASSIGNMENT_TYPE_MISMATCH!>"test"<!>
x.value <!UNRESOLVED_REFERENCE!>+=<!> "test" x.value <!UNRESOLVED_REFERENCE!>+=<!> "test"
} }
@@ -1,23 +0,0 @@
// WITH_STDLIB
// FILE: j/J.java
package j;
public class J {
public int getX() { return 1; }
protected void setX(int value) { throw new RuntimeException(); }
}
// FILE: main.kt
import j.*
class C : J() {
fun foo() {
<!INVISIBLE_SETTER!>J()<!UNNECESSARY_SAFE_CALL!>?.<!>x<!> = 1
}
}
fun box(): String {
C().foo()
return "OK"
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// WITH_STDLIB // WITH_STDLIB
// FILE: j/J.java // FILE: j/J.java
@@ -26,9 +26,9 @@ package foo
fun test(s: bar.Sub<String>) { fun test(s: bar.Sub<String>) {
s.<!INVISIBLE_REFERENCE!>name<!> s.<!INVISIBLE_REFERENCE!>name<!>
<!INVISIBLE_SETTER!>s.<!INVISIBLE_REFERENCE!>name<!><!> = "" s.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>name<!> = ""
s.name2 s.name2
<!INVISIBLE_SETTER!>s.name2<!> = "" s.<!INVISIBLE_SETTER!>name2<!> = ""
s.<!INVISIBLE_REFERENCE!>doSomething<!>() s.<!INVISIBLE_REFERENCE!>doSomething<!>()
s.doSomething2() s.doSomething2()
val s2: Super<String> = s val s2: Super<String> = s
@@ -41,7 +41,7 @@ open class A {
fun foo() { fun foo() {
<!UNRESOLVED_REFERENCE!>topLevelFun<!>() <!UNRESOLVED_REFERENCE!>topLevelFun<!>()
<!UNRESOLVED_REFERENCE!>topLevelFun<!>(1) <!UNRESOLVED_REFERENCE!>topLevelFun<!>(1)
<!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>topLevelProperty<!><!UNRESOLVED_REFERENCE!>++<!> <!UNRESOLVED_REFERENCE!>topLevelProperty<!><!UNRESOLVED_REFERENCE!>++<!>
"".<!UNRESOLVED_REFERENCE!>topLevelExtensionFun<!>() "".<!UNRESOLVED_REFERENCE!>topLevelExtensionFun<!>()
1.<!UNRESOLVED_REFERENCE!>topLevelExtensionFun<!>() 1.<!UNRESOLVED_REFERENCE!>topLevelExtensionFun<!>()
"".<!UNRESOLVED_REFERENCE!>topLevelExtensionProperty<!> "".<!UNRESOLVED_REFERENCE!>topLevelExtensionProperty<!>
@@ -35,12 +35,12 @@ fun test() {
bar { bar {
<!DSL_SCOPE_VIOLATION!>a<!> + 1 <!DSL_SCOPE_VIOLATION!>a<!> + 1
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a<!> += <!DSL_SCOPE_VIOLATION!>a<!> + 1 <!DSL_SCOPE_VIOLATION!>a<!> += <!DSL_SCOPE_VIOLATION!>a<!> + 1
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a<!>++ <!DSL_SCOPE_VIOLATION!>a<!>++
<!DSL_SCOPE_VIOLATION!>a1<!> + 1 <!DSL_SCOPE_VIOLATION!>a1<!> + 1
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a1<!> += <!DSL_SCOPE_VIOLATION!>a1<!> + 1 <!DSL_SCOPE_VIOLATION!>a1<!> += <!DSL_SCOPE_VIOLATION!>a1<!> + 1
<!DSL_SCOPE_VIOLATION, DSL_SCOPE_VIOLATION!>a1<!>++ <!DSL_SCOPE_VIOLATION!>a1<!>++
this@foo.a + 1 this@foo.a + 1
this@foo.a += this@foo.a + 1 this@foo.a += this@foo.a + 1
@@ -24,7 +24,7 @@ fun <T> bar() {
B::class.equals(<!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>T<!>) B::class.equals(<!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION!>T<!>)
T = "" <!TYPE_PARAMETER_IS_NOT_AN_EXPRESSION, VARIABLE_EXPECTED!>T<!> = ""
} }
fun baz(a: Any) {} fun baz(a: Any) {}
@@ -0,0 +1,9 @@
class A<T> {
public var x: Int = 0
private set
}
fun main() {
val a = A<Any>()
a.<!INVISIBLE_SETTER!>x<!> = 1
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
class A<T> { class A<T> {
public var x: Int = 0 public var x: Int = 0
private set private set
+1 -1
View File
@@ -8,6 +8,6 @@ class A {
class B() { class B() {
init { init {
<!INVISIBLE_SETTER!>A().<!INVISIBLE_REFERENCE!>a<!><!> = "Hello" A().<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>a<!> = "Hello"
} }
} }
+1 -1
View File
@@ -6,6 +6,6 @@ class A(private var i: Int, var j: Int) {
} }
fun test(a: A) { fun test(a: A) {
<!INVISIBLE_SETTER!>a.<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>i<!><!>++ a.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>i<!>++
a.j++ a.j++
} }
@@ -22,7 +22,7 @@ class B : A() {
b.bar = b.bar + "" b.bar = b.bar + ""
a.<!INVISIBLE_REFERENCE!>foo<!> a.<!INVISIBLE_REFERENCE!>foo<!>
<!INVISIBLE_SETTER!>a.bar<!> = a.bar + "" a.<!INVISIBLE_SETTER!>bar<!> = a.bar + ""
if (a is B) { if (a is B) {
a.foo a.foo
@@ -32,12 +32,12 @@ class B : A() {
if (d.x is B) { if (d.x is B) {
d.x.abc // Ok d.x.abc // Ok
d.x.<!INVISIBLE_REFERENCE!>foo<!> d.x.<!INVISIBLE_REFERENCE!>foo<!>
<!INVISIBLE_SETTER!>d.x.bar<!> = d.x.bar + "" d.x.<!INVISIBLE_SETTER!>bar<!> = d.x.bar + ""
} }
} }
} }
fun baz(a: A) { fun baz(a: A) {
a.<!INVISIBLE_REFERENCE!>foo<!> a.<!INVISIBLE_REFERENCE!>foo<!>
<!INVISIBLE_SETTER!>a.bar<!> = a.bar + "" a.<!INVISIBLE_SETTER!>bar<!> = a.bar + ""
} }
@@ -14,8 +14,8 @@ class Derived : Base() {
x.<!INVISIBLE_REFERENCE!>foo<!>() x.<!INVISIBLE_REFERENCE!>foo<!>()
x.<!INVISIBLE_REFERENCE!>bar<!>() x.<!INVISIBLE_REFERENCE!>bar<!>()
<!INVISIBLE_SETTER!>x.<!INVISIBLE_REFERENCE!>x<!><!> = x.<!INVISIBLE_REFERENCE!>x<!> + 1 x.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>x<!> = x.<!INVISIBLE_REFERENCE!>x<!> + 1
<!INVISIBLE_SETTER!>x.y<!> = x.y + 1 x.<!INVISIBLE_SETTER!>y<!> = x.y + 1
if (x is Derived) { if (x is Derived) {
x.foo() x.foo()
@@ -54,7 +54,7 @@ open class C : T {
} }
fun test4(c: C) { fun test4(c: C) {
<!INVISIBLE_SETTER!>c.<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>i<!><!>++ c.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>i<!>++
} }
class D : C() { class D : C() {
@@ -17,10 +17,10 @@ val testValLineBreakNoType
get() = 42 get() = 42
<!MUST_BE_INITIALIZED!>val testValLineBreakSemi: Int<!>; <!MUST_BE_INITIALIZED!>val testValLineBreakSemi: Int<!>;
<!VARIABLE_EXPECTED!>get()<!> = 42 <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = 42
<!MUST_BE_INITIALIZED!>val testValLineBreakSemiNoType<!>; <!MUST_BE_INITIALIZED!>val testValLineBreakSemiNoType<!>;
<!VARIABLE_EXPECTED!>get()<!> = 42 <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = 42
var testVarLineBreak: Int var testVarLineBreak: Int
get() = 42 get() = 42
@@ -31,9 +31,9 @@ get() = 42
set(value) {} set(value) {}
<!MUST_BE_INITIALIZED!>var testVarLineBreakSemi: Int<!>; <!MUST_BE_INITIALIZED!>var testVarLineBreakSemi: Int<!>;
<!VARIABLE_EXPECTED!>get()<!> = 42 <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = 42
<!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {} <!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {}
<!EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT!>var String.testExtVarLineBreakSemi: Int<!>; <!EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT!>var String.testExtVarLineBreakSemi: Int<!>;
<!VARIABLE_EXPECTED!>get()<!> = 42 <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = 42
<!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {} <!UNRESOLVED_REFERENCE!>set<!>(<!UNRESOLVED_REFERENCE!>value<!>) {}
@@ -8,7 +8,7 @@ fun foo(javaClass: JavaClass) {
javaClass.<!INVISIBLE_REFERENCE!>somethingProtected<!> javaClass.<!INVISIBLE_REFERENCE!>somethingProtected<!>
javaClass.<!INVISIBLE_REFERENCE!>somethingPrivate<!> javaClass.<!INVISIBLE_REFERENCE!>somethingPrivate<!>
javaClass.<!INVISIBLE_REFERENCE!>somethingPackage<!> javaClass.<!INVISIBLE_REFERENCE!>somethingPackage<!>
<!INVISIBLE_SETTER!>javaClass.somethingPublic<!> = 1 javaClass.<!INVISIBLE_SETTER!>somethingPublic<!> = 1
} }
// FILE: JavaClass.java // FILE: JavaClass.java
@@ -6,7 +6,7 @@ import JavaClass
fun foo(javaClass: JavaClass) { fun foo(javaClass: JavaClass) {
val v = javaClass.<!INVISIBLE_REFERENCE!>something<!> val v = javaClass.<!INVISIBLE_REFERENCE!>something<!>
javaClass.<!INVISIBLE_REFERENCE!>something<!> = 1 javaClass.<!INVISIBLE_REFERENCE!>something<!> = 1
javaClass.<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>something<!>++ javaClass.<!INVISIBLE_REFERENCE!>something<!>++
} }
// FILE: JavaClass.java // FILE: JavaClass.java
@@ -15,23 +15,23 @@ class Test<in I, out O> {
this.i = getT() this.i = getT()
with(Test<I, O>()) { with(Test<I, O>()) {
i = getT() // resolved to this@Test.i i = getT() // resolved to this@Test.i
<!INVISIBLE_SETTER!>this.<!INVISIBLE_REFERENCE!>i<!><!> = getT() this.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>i<!> = getT()
<!INVISIBLE_SETTER!>this@with.<!INVISIBLE_REFERENCE!>i<!><!> = getT() this@with.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>i<!> = getT()
this@Test.i = getT() this@Test.i = getT()
} }
} }
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
<!INVISIBLE_SETTER!>t.<!INVISIBLE_REFERENCE!>i<!><!> = getT() t.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>i<!> = getT()
} }
companion object { companion object {
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
<!INVISIBLE_SETTER!>t.<!INVISIBLE_REFERENCE!>i<!><!> = getT() t.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>i<!> = getT()
} }
} }
} }
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
<!INVISIBLE_SETTER!>t.<!INVISIBLE_REFERENCE!>i<!><!> = getT() t.<!INVISIBLE_REFERENCE, INVISIBLE_SETTER!>i<!> = getT()
} }
@@ -18,12 +18,12 @@ class Data(var x: Foo)
class B : Foo() { class B : Foo() {
fun baz(a: Foo, t: Foo, d: Data) { fun baz(a: Foo, t: Foo, d: Data) {
<!INVISIBLE_SETTER!>a.bar<!> = t.bar a.<!INVISIBLE_SETTER!>bar<!> = t.bar
<!INVISIBLE_SETTER!>a.foo<!> = t.foo a.<!INVISIBLE_SETTER!>foo<!> = t.foo
if (d.x is B) { if (d.x is B) {
<!INVISIBLE_SETTER!>d.x.bar<!> = d.x.bar + "" d.x.<!INVISIBLE_SETTER!>bar<!> = d.x.bar + ""
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + "" d.x.<!INVISIBLE_SETTER!>foo<!> = d.x.foo + ""
} }
} }
} }
@@ -19,11 +19,11 @@ class Data(var x: Foo)
class B : Foo() { class B : Foo() {
fun baz(a: Foo, t: Foo, d: Data) { fun baz(a: Foo, t: Foo, d: Data) {
a.bar = t.bar a.bar = t.bar
<!INVISIBLE_SETTER!>a.foo<!> = t.foo a.<!INVISIBLE_SETTER!>foo<!> = t.foo
if (d.x is B) { if (d.x is B) {
d.x.bar = d.x.bar + "" d.x.bar = d.x.bar + ""
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + "" d.x.<!INVISIBLE_SETTER!>foo<!> = d.x.foo + ""
} }
} }
} }
@@ -13,11 +13,11 @@ class Data(var x: Foo)
class B : Foo() { class B : Foo() {
fun baz(a: Foo, t: Foo, d: Data) { fun baz(a: Foo, t: Foo, d: Data) {
a.bar = t.bar a.bar = t.bar
<!INVISIBLE_SETTER!>a.foo<!> = t.foo a.<!INVISIBLE_SETTER!>foo<!> = t.foo
if (d.x is B) { if (d.x is B) {
d.x.bar = d.x.bar + "" d.x.bar = d.x.bar + ""
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + "" d.x.<!INVISIBLE_SETTER!>foo<!> = d.x.foo + ""
} }
} }
} }
@@ -12,10 +12,10 @@ fun main(arg: Any) {
run { a; this }.a = <!ASSIGNMENT_TYPE_MISMATCH!>10<!> run { a; this }.a = <!ASSIGNMENT_TYPE_MISMATCH!>10<!>
a += 1 a += 1
this.a = <!ASSIGNMENT_TYPE_MISMATCH!>57<!> this.a = <!ASSIGNMENT_TYPE_MISMATCH!>57<!>
this.(a) = 57 this.<!ILLEGAL_SELECTOR, VARIABLE_EXPECTED!>(a)<!> = 57
a = <!ASSIGNMENT_TYPE_MISMATCH!>x<!> a = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
(a) = <!ASSIGNMENT_TYPE_MISMATCH!>x<!> (a) = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
a.<!FUNCTION_CALL_EXPECTED!>hashCode<!> = 99 a.<!FUNCTION_CALL_EXPECTED, VARIABLE_EXPECTED!>hashCode<!> = 99
if (arg is String) { if (arg is String) {
a = arg a = arg
} }
@@ -4174,6 +4174,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt"); runTest("compiler/testData/diagnostics/tests/cast/AsInBlockWithReturnType.kt");
} }
@Test
@TestMetadata("AsInCompoundAssignment.kt")
public void testAsInCompoundAssignment() throws Exception {
runTest("compiler/testData/diagnostics/tests/cast/AsInCompoundAssignment.kt");
}
@Test @Test
@TestMetadata("AsInExpressionBody.kt") @TestMetadata("AsInExpressionBody.kt")
public void testAsInExpressionBody() throws Exception { public void testAsInExpressionBody() throws Exception {
@@ -54,5 +54,5 @@ fun case3() {
fun case4() { fun case4() {
<!VARIABLE_EXPECTED!>for (x in 1..2) {}<!> = TODO(); <!VARIABLE_EXPECTED!>for (x in 1..2) {}<!> = TODO();
<!VARIABLE_EXPECTED!>while (false) { }<!> = TODO() <!EXPRESSION_EXPECTED, VARIABLE_EXPECTED!>while (false) { }<!> = TODO()
} }
@@ -9,7 +9,7 @@ fun case1() {
val x : Case1? = Case1() val x : Case1? = Case1()
x.<!VAL_REASSIGNMENT!>x<!> = "0" x.<!VAL_REASSIGNMENT!>x<!> = "0"
x?.<!VAL_REASSIGNMENT!>x<!> = "0" x?.<!VAL_REASSIGNMENT!>x<!> = "0"
<!VARIABLE_EXPECTED!>x::x<!> = TODO() <!VARIABLE_EXPECTED!>x::<!UNRESOLVED_REFERENCE!>x<!><!> = TODO()
} }
class Case1{ class Case1{
@@ -25,7 +25,7 @@ fun case2() {
val x : Case2? = Case2(null) val x : Case2? = Case2(null)
x.<!VAL_REASSIGNMENT!>x<!> = "0" x.<!VAL_REASSIGNMENT!>x<!> = "0"
x?.<!VAL_REASSIGNMENT!>x<!> = "0" x?.<!VAL_REASSIGNMENT!>x<!> = "0"
<!VARIABLE_EXPECTED!>x::x<!> = TODO() <!VARIABLE_EXPECTED!>x::<!UNRESOLVED_REFERENCE!>x<!><!> = TODO()
} }
class Case2(val x: Any?) {} class Case2(val x: Any?) {}
@@ -38,7 +38,7 @@ fun case3() {
val x : Case3? = Case3() val x : Case3? = Case3()
x.<!VAL_REASSIGNMENT!>x<!> = "0" x.<!VAL_REASSIGNMENT!>x<!> = "0"
x?.<!VAL_REASSIGNMENT!>x<!> = "0" x?.<!VAL_REASSIGNMENT!>x<!> = "0"
<!VARIABLE_EXPECTED!>x::x<!> = TODO() <!VARIABLE_EXPECTED!>x::<!UNRESOLVED_REFERENCE!>x<!><!> = TODO()
} }
class Case3() { class Case3() {
@@ -5,7 +5,7 @@
fun case_1() { fun case_1() {
var x: Int? = 11 var x: Int? = 11
x!! x!!
try {x = null;} finally { <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!> <!UNSAFE_OPERATOR_CALL!>+=<!> 10; } try {x = null;} finally { <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!> <!UNSAFE_OPERATOR_CALL!>+=<!> 10; }
} }
// TESTCASE NUMBER: 2 // TESTCASE NUMBER: 2