Change Signature: val/var parameter support
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.Override;
|
||||
|
||||
class J extends A {
|
||||
private int p;
|
||||
|
||||
public J() {
|
||||
super(0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getS() {
|
||||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setS(@NotNull String value) {
|
||||
p = value;
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
static void test() {
|
||||
new A(0).getS();
|
||||
new A(0).setS(1);
|
||||
|
||||
new B(0).getS();
|
||||
new B(0).setS(2);
|
||||
|
||||
new C().getS();
|
||||
new C().setS(3);
|
||||
|
||||
new J().getS();
|
||||
new J().setS(4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
open class A(open var <caret>s: String)
|
||||
|
||||
class B(override var s: String): A(s)
|
||||
|
||||
class C: A(0) {
|
||||
override var s: String = 1
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val t1 = A(0).s
|
||||
A(0).s = 1
|
||||
|
||||
val t2 = B(0).s
|
||||
B(0).s = 2
|
||||
|
||||
val t3 = C().s
|
||||
C().s = 3
|
||||
|
||||
val t4 = J().getS()
|
||||
J().setS(4)
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import java.lang.Override;
|
||||
|
||||
class J extends A {
|
||||
private int p;
|
||||
|
||||
public J() {
|
||||
super(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getP() {
|
||||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setP(int value) {
|
||||
p = value;
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
static void test() {
|
||||
new A(0).getP();
|
||||
new A(0).setP(1);
|
||||
|
||||
new B(0).getP();
|
||||
new B(0).setP(2);
|
||||
|
||||
new C().getP();
|
||||
new C().setP(3);
|
||||
|
||||
new J().getP();
|
||||
new J().setP(4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
open class A(open var <caret>p: Int)
|
||||
|
||||
class B(override var p: Int): A(p)
|
||||
|
||||
class C: A(0) {
|
||||
override var p: Int = 1
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val t1 = A(0).p
|
||||
A(0).p = 1
|
||||
|
||||
val t2 = B(0).p
|
||||
B(0).p = 2
|
||||
|
||||
val t3 = C().p
|
||||
C().p = 3
|
||||
|
||||
val t4 = J().getP()
|
||||
J().setP(4)
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
open class C1 protected (<caret>val x1: Int = 1, var x2: Float, x3: ((Int) -> Int)?) {
|
||||
open class C1 protected <caret>(val x1: Int = 1, var x2: Float, x3: ((Int) -> Int)?) {
|
||||
fun bar() {
|
||||
val y1 = x1;
|
||||
val y2 = x2;
|
||||
|
||||
Reference in New Issue
Block a user