[FIR] Add INVISIBLE_SETTER
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
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.prop = 12
|
||||
|
||||
val itest: ITest = test
|
||||
itest.prop = 12 // No error here
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
public interface ITest {
|
||||
public var prop : Int
|
||||
get() = 12
|
||||
|
||||
@@ -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<!>() {}
|
||||
|
||||
+2
-2
@@ -28,14 +28,14 @@ fun test(s: bar.Sub<String>) {
|
||||
s.<!INVISIBLE_REFERENCE!>name<!>
|
||||
s.<!INVISIBLE_REFERENCE!>name<!> = ""
|
||||
s.name2
|
||||
s.name2 = ""
|
||||
<!INVISIBLE_SETTER!>s.name2<!> = ""
|
||||
s.<!INVISIBLE_REFERENCE!>doSomething<!>()
|
||||
s.doSomething2()
|
||||
val s2: Super<String> = s
|
||||
s2.<!INVISIBLE_REFERENCE!>name<!>
|
||||
s2.<!INVISIBLE_REFERENCE!>name<!> = ""
|
||||
s2.name2
|
||||
s2.name2 = ""
|
||||
<!INVISIBLE_SETTER!>s2.name2<!> = ""
|
||||
s2.<!INVISIBLE_REFERENCE!>doSomething<!>()
|
||||
s2.doSomething2()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FIR_IDENTICAL
|
||||
class Test(protected var prop1: Int = 1) {
|
||||
protected var prop2: Int = 2
|
||||
|
||||
private fun test() {
|
||||
prop1 = 3
|
||||
prop2 = 4
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public final class Test {
|
||||
public constructor Test(/*0*/ prop1: kotlin.Int = ...)
|
||||
protected final var prop1: kotlin.Int
|
||||
protected final var prop2: 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
|
||||
private final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+3
-5
@@ -22,8 +22,7 @@ class B : A() {
|
||||
b.bar = b.bar + ""
|
||||
|
||||
a.<!INVISIBLE_REFERENCE!>foo<!>
|
||||
// TODO: should be INVISIBLE_SETTER
|
||||
a.bar = a.bar + ""
|
||||
<!INVISIBLE_SETTER!>a.bar<!> = a.bar + ""
|
||||
|
||||
if (a is B) {
|
||||
a.foo
|
||||
@@ -33,13 +32,12 @@ class B : A() {
|
||||
if (d.x is B) {
|
||||
d.x.abc // Ok
|
||||
d.x.<!INVISIBLE_REFERENCE!>foo<!>
|
||||
// TODO: should be INVISIBLE_SETTER
|
||||
d.x.bar = d.x.bar + ""
|
||||
<!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 + ""
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ class Derived : Base() {
|
||||
x.<!INVISIBLE_REFERENCE!>bar<!>()
|
||||
|
||||
x.<!INVISIBLE_REFERENCE!>x<!> = x.<!INVISIBLE_REFERENCE!>x<!> + 1
|
||||
x.y = x.y + 1
|
||||
<!INVISIBLE_SETTER!>x.y<!> = x.y + 1
|
||||
|
||||
if (x is Derived) {
|
||||
x.foo()
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
// FILE: Java.java
|
||||
|
||||
public abstract class Java {
|
||||
private String _name = null;
|
||||
|
||||
void setName(String name) {
|
||||
this._name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun Java.test(name: String) {
|
||||
this.name = name
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun Java.test(/*0*/ name: kotlin.String): kotlin.Unit
|
||||
|
||||
public abstract class Java {
|
||||
public constructor Java()
|
||||
private final var _name: kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun getName(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public/*package*/ open fun setName(/*0*/ name: kotlin.String!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+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
|
||||
|
||||
+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