[FIR] Implement INVISIBLE_SETTER
This commit is contained in:
committed by
teamcityserver
parent
ca4410aa53
commit
b3d7ed569d
@@ -22,7 +22,7 @@ class Test: ATest(), ITest {
|
||||
|
||||
fun main() {
|
||||
val test = Test()
|
||||
test.prop = 12
|
||||
<!INVISIBLE_SETTER!>test.prop<!> = 12
|
||||
|
||||
val itest: ITest = test
|
||||
itest.prop = 12 // No error here
|
||||
|
||||
@@ -23,23 +23,23 @@ class P {
|
||||
|
||||
fun foo() {
|
||||
val p = P()
|
||||
p.x = 34 //should be an error here
|
||||
<!INVISIBLE_SETTER!>p.x<!> = 34 //should be an error here
|
||||
p.y = 23
|
||||
|
||||
fun inner() {
|
||||
p.x = 44
|
||||
<!INVISIBLE_SETTER!>p.x<!> = 44
|
||||
}
|
||||
}
|
||||
|
||||
class R {
|
||||
val p = P();
|
||||
init {
|
||||
p.x = 42
|
||||
<!INVISIBLE_SETTER!>p.x<!> = 42
|
||||
}
|
||||
|
||||
val testInGetterInOtherClass : Int
|
||||
get() {
|
||||
p.x = 33
|
||||
<!INVISIBLE_SETTER!>p.x<!> = 33
|
||||
return 3
|
||||
}
|
||||
}
|
||||
@@ -50,4 +50,4 @@ fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>p<!>.x = 43
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//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.x = 32 }
|
||||
|
||||
val o = object {
|
||||
fun run() {
|
||||
p.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,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
//KT-2960 Perform control flow checks for package property initializers
|
||||
|
||||
package b
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
open class X(s : String) {
|
||||
public var n: String = s
|
||||
private set
|
||||
|
||||
}
|
||||
|
||||
class Z : X("subclass") {
|
||||
fun print(): String {
|
||||
n = n
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box() : String {
|
||||
return Z().print() //error
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
open class X(s : String) {
|
||||
public var n: String = s
|
||||
private set
|
||||
|
||||
@@ -40,7 +40,7 @@ fun test() {
|
||||
val po = <!INVISIBLE_REFERENCE!>PO<!>
|
||||
|
||||
val v = xx
|
||||
xx = 40
|
||||
<!INVISIBLE_SETTER("xx; private; file")!>xx<!> = 40
|
||||
}
|
||||
|
||||
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE!>A<!>() {}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class A<T> {
|
||||
public var x: Int = 0
|
||||
private set
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val a = A<Any>()
|
||||
a.x = 1
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
class A<T> {
|
||||
public var x: Int = 0
|
||||
private set
|
||||
|
||||
@@ -6,8 +6,8 @@ class B: A()
|
||||
|
||||
class C: A() {
|
||||
fun bar() {
|
||||
A().foo()
|
||||
B().foo()
|
||||
A().<!INVISIBLE_REFERENCE!>foo<!>()
|
||||
B().<!INVISIBLE_REFERENCE!>foo<!>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ class B {
|
||||
|
||||
class C: A() {
|
||||
init {
|
||||
B.foo() // Error: receiver is not suitable
|
||||
B.<!INVISIBLE_REFERENCE!>foo<!>() // Error: receiver is not suitable
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+5
-7
@@ -21,9 +21,8 @@ class B : A() {
|
||||
b.foo
|
||||
b.bar = b.bar + ""
|
||||
|
||||
a.foo
|
||||
// TODO: should be INVISIBLE_SETTER
|
||||
a.bar = a.bar + ""
|
||||
a.<!INVISIBLE_REFERENCE!>foo<!>
|
||||
<!INVISIBLE_SETTER!>a.bar<!> = a.bar + ""
|
||||
|
||||
if (a is B) {
|
||||
a.foo
|
||||
@@ -32,14 +31,13 @@ class B : A() {
|
||||
|
||||
if (d.x is B) {
|
||||
d.x.abc // Ok
|
||||
d.x.foo
|
||||
// TODO: should be INVISIBLE_SETTER
|
||||
d.x.bar = d.x.bar + ""
|
||||
d.x.<!INVISIBLE_REFERENCE!>foo<!>
|
||||
<!INVISIBLE_SETTER!>d.x.bar<!> = d.x.bar + ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun baz(a: A) {
|
||||
a.<!INVISIBLE_REFERENCE!>foo<!>
|
||||
a.bar = a.bar + ""
|
||||
<!INVISIBLE_SETTER!>a.bar<!> = a.bar + ""
|
||||
}
|
||||
|
||||
Vendored
-2
@@ -22,7 +22,6 @@ class B : A() {
|
||||
b.bar = b.bar + ""
|
||||
|
||||
a.<!INVISIBLE_MEMBER!>foo<!>
|
||||
// TODO: should be INVISIBLE_SETTER
|
||||
a.<!INVISIBLE_SETTER!>bar<!> = a.bar + ""
|
||||
|
||||
if (a is B) {
|
||||
@@ -33,7 +32,6 @@ class B : A() {
|
||||
if (d.x is B) {
|
||||
d.x.abc // Ok
|
||||
d.x.<!INVISIBLE_MEMBER!>foo<!>
|
||||
// TODO: should be INVISIBLE_SETTER
|
||||
d.x.<!INVISIBLE_SETTER!>bar<!> = d.x.bar + ""
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -11,7 +11,7 @@ class Data(var x: A)
|
||||
|
||||
class B : A() {
|
||||
fun baz(a: A, b: B, d: Data) {
|
||||
a.foo { }
|
||||
a.<!INVISIBLE_REFERENCE!>foo<!> { }
|
||||
|
||||
b.foo { }
|
||||
|
||||
@@ -20,7 +20,7 @@ class B : A() {
|
||||
}
|
||||
|
||||
if (d.x is B) {
|
||||
d.x.foo {}
|
||||
d.x.<!INVISIBLE_REFERENCE!>foo<!> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ fun BaseOuter.foo(): String = ""
|
||||
class Derived : BaseOuter() {
|
||||
fun test(foo: Foo) {
|
||||
if (foo.base is Derived) {
|
||||
foo.base.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() } // Resolved to extension
|
||||
foo.base.bar()
|
||||
foo.base.foo() checkType { _<String>() } // Resolved to extension
|
||||
foo.base.<!INVISIBLE_REFERENCE!>bar<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -11,11 +11,11 @@ class Derived : Base() {
|
||||
override fun bar() { }
|
||||
|
||||
protected fun baz(x: Base) {
|
||||
x.foo()
|
||||
x.bar()
|
||||
x.<!INVISIBLE_REFERENCE!>foo<!>()
|
||||
x.<!INVISIBLE_REFERENCE!>bar<!>()
|
||||
|
||||
x.x = x.x + 1
|
||||
x.y = x.y + 1
|
||||
x.<!INVISIBLE_REFERENCE!>x<!> = x.<!INVISIBLE_REFERENCE!>x<!> + 1
|
||||
<!INVISIBLE_SETTER!>x.y<!> = x.y + 1
|
||||
|
||||
if (x is Derived) {
|
||||
x.foo()
|
||||
|
||||
@@ -72,7 +72,7 @@ class E : C() {
|
||||
|
||||
class F : C() {
|
||||
fun test8(c: C) {
|
||||
doSmth(c.i)
|
||||
doSmth(c.<!INVISIBLE_REFERENCE!>i<!>)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ fun foo(javaClass: JavaClass) {
|
||||
javaClass.<!INVISIBLE_REFERENCE!>somethingProtected<!>
|
||||
javaClass.<!INVISIBLE_REFERENCE!>somethingPrivate<!>
|
||||
javaClass.<!INVISIBLE_REFERENCE!>somethingPackage<!>
|
||||
javaClass.somethingPublic = 1
|
||||
<!INVISIBLE_SETTER!>javaClass.somethingPublic<!> = 1
|
||||
}
|
||||
|
||||
// FILE: JavaClass.java
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ fun foo(javaClass: JavaClass) {
|
||||
class X : JavaClass() {
|
||||
fun foo(other: JavaClass) {
|
||||
doSomething { bar() }
|
||||
other.doSomething { bar() }
|
||||
other.<!INVISIBLE_REFERENCE!>doSomething<!> { bar() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -18,12 +18,12 @@ class Data(var x: Foo)
|
||||
|
||||
class B : Foo() {
|
||||
fun baz(a: Foo, t: Foo, d: Data) {
|
||||
a.bar = t.bar
|
||||
a.foo = t.foo
|
||||
<!INVISIBLE_SETTER!>a.bar<!> = t.bar
|
||||
<!INVISIBLE_SETTER!>a.foo<!> = t.foo
|
||||
|
||||
if (d.x is B) {
|
||||
d.x.bar = d.x.bar + ""
|
||||
d.x.foo = d.x.foo + ""
|
||||
<!INVISIBLE_SETTER!>d.x.bar<!> = d.x.bar + ""
|
||||
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -19,11 +19,11 @@ class Data(var x: Foo)
|
||||
class B : Foo() {
|
||||
fun baz(a: Foo, t: Foo, d: Data) {
|
||||
a.bar = t.bar
|
||||
a.foo = t.foo
|
||||
<!INVISIBLE_SETTER!>a.foo<!> = t.foo
|
||||
|
||||
if (d.x is B) {
|
||||
d.x.bar = d.x.bar + ""
|
||||
d.x.foo = d.x.foo + ""
|
||||
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -13,11 +13,11 @@ class Data(var x: Foo)
|
||||
class B : Foo() {
|
||||
fun baz(a: Foo, t: Foo, d: Data) {
|
||||
a.bar = t.bar
|
||||
a.foo = t.foo
|
||||
<!INVISIBLE_SETTER!>a.foo<!> = t.foo
|
||||
|
||||
if (d.x is B) {
|
||||
d.x.bar = d.x.bar + ""
|
||||
d.x.foo = d.x.foo + ""
|
||||
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user