Revert "[FIR] Implement INVISIBLE_SETTER"

This reverts commit b3d7ed56
This commit is contained in:
Ivan Kochurkin
2021-08-02 19:21:26 +03:00
parent b264a2e5dd
commit afb85026c4
39 changed files with 180 additions and 288 deletions
@@ -23,7 +23,7 @@ class Test: ATest(), ITest {
fun main() {
val test = Test()
<!INVISIBLE_SETTER!>test.prop<!> = 12
test.prop = 12
val itest: ITest = test
itest.prop = 12 // No error here
@@ -23,23 +23,23 @@ class P {
fun foo() {
val p = P()
<!INVISIBLE_SETTER!>p.x<!> = 34 //should be an error here
p.x = 34 //should be an error here
p.y = 23
fun inner() {
<!INVISIBLE_SETTER!>p.x<!> = 44
p.x = 44
}
}
class R {
val p = P();
init {
<!INVISIBLE_SETTER!>p.x<!> = 42
p.x = 42
}
val testInGetterInOtherClass : Int
get() {
<!INVISIBLE_SETTER!>p.x<!> = 33
p.x = 33
return 3
}
}
@@ -50,4 +50,4 @@ fun test() {
<!UNRESOLVED_REFERENCE!>p<!>.x = 43
}
}
}
}
@@ -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.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,4 +1,3 @@
// FIR_IDENTICAL
//KT-2960 Perform control flow checks for package property initializers
package b
@@ -0,0 +1,17 @@
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,4 +1,3 @@
// 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
<!INVISIBLE_SETTER("xx; private; file")!>xx<!> = 40
xx = 40
}
class B : <!EXPOSED_SUPER_CLASS, INVISIBLE_REFERENCE!>A<!>() {}
@@ -0,0 +1,9 @@
class A<T> {
public var x: Int = 0
private set
}
fun main() {
val a = A<Any>()
a.x = 1
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
class A<T> {
public var x: Int = 0
private set
+2 -2
View File
@@ -6,8 +6,8 @@ class B: A()
class C: A() {
fun bar() {
A().<!INVISIBLE_REFERENCE!>foo<!>()
B().<!INVISIBLE_REFERENCE!>foo<!>()
A().foo()
B().foo()
}
}
@@ -13,6 +13,6 @@ class B {
class C: A() {
init {
B.<!INVISIBLE_REFERENCE!>foo<!>() // Error: receiver is not suitable
B.foo() // Error: receiver is not suitable
}
}
@@ -21,8 +21,9 @@ class B : A() {
b.foo
b.bar = b.bar + ""
a.<!INVISIBLE_REFERENCE!>foo<!>
<!INVISIBLE_SETTER!>a.bar<!> = a.bar + ""
a.foo
// TODO: should be INVISIBLE_SETTER
a.bar = a.bar + ""
if (a is B) {
a.foo
@@ -31,13 +32,14 @@ class B : A() {
if (d.x is B) {
d.x.abc // Ok
d.x.<!INVISIBLE_REFERENCE!>foo<!>
<!INVISIBLE_SETTER!>d.x.bar<!> = d.x.bar + ""
d.x.foo
// TODO: should be INVISIBLE_SETTER
d.x.bar = d.x.bar + ""
}
}
}
fun baz(a: A) {
a.<!INVISIBLE_REFERENCE!>foo<!>
<!INVISIBLE_SETTER!>a.bar<!> = a.bar + ""
a.bar = a.bar + ""
}
@@ -22,6 +22,7 @@ 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) {
@@ -32,6 +33,7 @@ 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 + ""
}
}
@@ -11,7 +11,7 @@ class Data(var x: A)
class B : A() {
fun baz(a: A, b: B, d: Data) {
a.<!INVISIBLE_REFERENCE!>foo<!> { }
a.foo { }
b.foo { }
@@ -20,7 +20,7 @@ class B : A() {
}
if (d.x is B) {
d.x.<!INVISIBLE_REFERENCE!>foo<!> {}
d.x.foo {}
}
}
}
@@ -11,8 +11,8 @@ fun BaseOuter.foo(): String = ""
class Derived : BaseOuter() {
fun test(foo: Foo) {
if (foo.base is Derived) {
foo.base.foo() checkType { _<String>() } // Resolved to extension
foo.base.<!INVISIBLE_REFERENCE!>bar<!>()
foo.base.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() } // Resolved to extension
foo.base.bar()
}
}
}
@@ -11,11 +11,11 @@ class Derived : Base() {
override fun bar() { }
protected fun baz(x: Base) {
x.<!INVISIBLE_REFERENCE!>foo<!>()
x.<!INVISIBLE_REFERENCE!>bar<!>()
x.foo()
x.bar()
x.<!INVISIBLE_REFERENCE!>x<!> = x.<!INVISIBLE_REFERENCE!>x<!> + 1
<!INVISIBLE_SETTER!>x.y<!> = x.y + 1
x.x = x.x + 1
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.<!INVISIBLE_REFERENCE!>i<!>)
doSmth(c.i)
}
}
@@ -8,7 +8,7 @@ fun foo(javaClass: JavaClass) {
javaClass.<!INVISIBLE_REFERENCE!>somethingProtected<!>
javaClass.<!INVISIBLE_REFERENCE!>somethingPrivate<!>
javaClass.<!INVISIBLE_REFERENCE!>somethingPackage<!>
<!INVISIBLE_SETTER!>javaClass.somethingPublic<!> = 1
javaClass.somethingPublic = 1
}
// FILE: JavaClass.java
@@ -12,7 +12,7 @@ fun foo(javaClass: JavaClass) {
class X : JavaClass() {
fun foo(other: JavaClass) {
doSomething { bar() }
other.<!INVISIBLE_REFERENCE!>doSomething<!> { bar() }
other.doSomething { bar() }
}
}
@@ -18,12 +18,12 @@ class Data(var x: Foo)
class B : Foo() {
fun baz(a: Foo, t: Foo, d: Data) {
<!INVISIBLE_SETTER!>a.bar<!> = t.bar
<!INVISIBLE_SETTER!>a.foo<!> = t.foo
a.bar = t.bar
a.foo = t.foo
if (d.x is B) {
<!INVISIBLE_SETTER!>d.x.bar<!> = d.x.bar + ""
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + ""
d.x.bar = d.x.bar + ""
d.x.foo = d.x.foo + ""
}
}
}
@@ -19,11 +19,11 @@ class Data(var x: Foo)
class B : Foo() {
fun baz(a: Foo, t: Foo, d: Data) {
a.bar = t.bar
<!INVISIBLE_SETTER!>a.foo<!> = t.foo
a.foo = t.foo
if (d.x is B) {
d.x.bar = d.x.bar + ""
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + ""
d.x.foo = d.x.foo + ""
}
}
}
@@ -13,11 +13,11 @@ class Data(var x: Foo)
class B : Foo() {
fun baz(a: Foo, t: Foo, d: Data) {
a.bar = t.bar
<!INVISIBLE_SETTER!>a.foo<!> = t.foo
a.foo = t.foo
if (d.x is B) {
d.x.bar = d.x.bar + ""
<!INVISIBLE_SETTER!>d.x.foo<!> = d.x.foo + ""
d.x.foo = d.x.foo + ""
}
}
}