KT-12046 Java to Kotlin dangerous conversion (recursive property set)
#KT-12046 Fixed
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
public class C {
|
||||
private String x = null;
|
||||
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
void setX(String x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
var x: String? = null
|
||||
internal set
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
C other = null;
|
||||
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
void setX(String x) {
|
||||
System.out.println("setter invoked");
|
||||
if (other != null) {
|
||||
this.other.x = x;
|
||||
}
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
private var x = ""
|
||||
internal var other: C? = null
|
||||
|
||||
fun getX(): String {
|
||||
return x
|
||||
}
|
||||
|
||||
internal fun setX(x: String) {
|
||||
println("setter invoked")
|
||||
if (other != null) {
|
||||
this.other!!.x = x
|
||||
}
|
||||
this.x = x
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class AAA {
|
||||
var x = 42
|
||||
set(x) {
|
||||
this.x += x
|
||||
field += x
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
public class C {
|
||||
private String myX = "";
|
||||
|
||||
public String getX() {
|
||||
System.out.println("getter invoked");
|
||||
return myX;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
this.myX = x;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
System.out.println("myX = " + myX);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
private var myX = ""
|
||||
|
||||
var x: String
|
||||
get() {
|
||||
println("getter invoked")
|
||||
return myX
|
||||
}
|
||||
set(x) {
|
||||
this.myX = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
println("myX = " + myX)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
|
||||
public String getX() {
|
||||
System.out.println("getter invoked");
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
System.out.println("x = " + x);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
private var x = ""
|
||||
|
||||
fun getX(): String {
|
||||
println("getter invoked")
|
||||
return x
|
||||
}
|
||||
|
||||
fun setX(x: String) {
|
||||
this.x = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
println("x = " + x)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class C {
|
||||
public String x = "";
|
||||
|
||||
public String getX() {
|
||||
System.out.println("getter invoked");
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
var x = ""
|
||||
|
||||
fun getX(): String {
|
||||
println("getter invoked")
|
||||
return x
|
||||
}
|
||||
|
||||
fun setX(x: String) {
|
||||
this.x = x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
|
||||
public String getX() {
|
||||
System.out.println("getter invoked");
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
var x = ""
|
||||
get() {
|
||||
println("getter invoked")
|
||||
return field
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
|
||||
public String getX() {
|
||||
System.out.println("getter invoked");
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
var x = ""
|
||||
get() {
|
||||
println("getter invoked")
|
||||
return field
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
class C {
|
||||
private int aaa = 0;
|
||||
private int bbb = 0;
|
||||
private int ccc = 0;
|
||||
private int ddd = 0;
|
||||
|
||||
public int getAaa() {
|
||||
return bbb;
|
||||
}
|
||||
|
||||
public int getBbb() {
|
||||
return ccc;
|
||||
}
|
||||
|
||||
public int getCcc() {
|
||||
return ddd;
|
||||
}
|
||||
|
||||
public int getDdd() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
internal class C {
|
||||
private val aaa = 0
|
||||
private val bbb = 0
|
||||
private val ccc = 0
|
||||
private val ddd = 0
|
||||
|
||||
fun getAaa(): Int {
|
||||
return bbb
|
||||
}
|
||||
|
||||
fun getBbb(): Int {
|
||||
return ccc
|
||||
}
|
||||
|
||||
fun getCcc(): Int {
|
||||
return ddd
|
||||
}
|
||||
|
||||
fun getDdd(): Int {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class C {
|
||||
private String myX = "";
|
||||
|
||||
public String getX() {
|
||||
return myX;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
System.out.println("setter invoked");
|
||||
this.myX = x;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
myX = "a";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class C {
|
||||
private var myX = ""
|
||||
|
||||
var x: String
|
||||
get() = myX
|
||||
set(x) {
|
||||
println("setter invoked")
|
||||
this.myX = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
myX = "a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
System.out.println("setter invoked");
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
x = "a";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
private var x = ""
|
||||
|
||||
fun getX(): String {
|
||||
return x
|
||||
}
|
||||
|
||||
fun setX(x: String) {
|
||||
println("setter invoked")
|
||||
this.x = x
|
||||
}
|
||||
|
||||
internal fun foo() {
|
||||
x = "a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class C {
|
||||
protected String x = "";
|
||||
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
System.out.println("setter invoked");
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
protected var x = ""
|
||||
|
||||
fun getX(): String {
|
||||
return x
|
||||
}
|
||||
|
||||
fun setX(x: String) {
|
||||
println("setter invoked")
|
||||
this.x = x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String value) {
|
||||
System.out.println("setter invoked");
|
||||
x = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
var x = ""
|
||||
set(value) {
|
||||
println("setter invoked")
|
||||
field = value
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
System.out.println("setter invoked");
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
var x = ""
|
||||
set(x) {
|
||||
println("setter invoked")
|
||||
field = x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class C {
|
||||
private String x = "";
|
||||
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(String x) {
|
||||
System.out.println("old value: " + this.x);
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
var x = ""
|
||||
set(x) {
|
||||
println("old value: " + this.x)
|
||||
field = x
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user