J2K breaks code if applied to a java class with static field which is accessed from another java class

#KT-11587 Fixed
This commit is contained in:
Natalia Ukhorskaya
2016-03-24 14:36:46 +03:00
parent c7ae9981cb
commit 79bac598bf
16 changed files with 97 additions and 72 deletions
+2
View File
@@ -8,4 +8,6 @@ public class JavaClass {
public int getProperty() {
return myProperty;
}
public static final String NAME = "Bar";
}
+5
View File
@@ -5,4 +5,9 @@ open class JavaClass {
var property = 0
protected set
companion object {
val NAME = "Bar"
}
}
@@ -9,5 +9,7 @@ public class C extends JavaClass {
field = myProperty;
field *= 2;
field = field * 2;
String s = JavaClass.NAME;
}
}
@@ -9,5 +9,7 @@ public class C extends JavaClass {
setField(getProperty());
setField(getField() * 2);
setField(getField() * 2);
String s = JavaClass.Companion.getNAME();
}
}
@@ -6,6 +6,7 @@ class ClassWithStatics {
public static void staticMethod(int p) {}
public static final int staticField = 1;
public static int staticNonFinalField = 1;
protected static int ourValue = 0;
@@ -10,6 +10,7 @@ internal open class ClassWithStatics {
}
val staticField = 1
var staticNonFinalField = 1
var value = 0
}
@@ -4,7 +4,7 @@ class C {
void foo(ClassWithStatics c) {
ClassWithStatics.staticMethod(ClassWithStatics.staticField);
c.instanceMethod();
ClassWithStatics.staticField += 2;
ClassWithStatics.staticNonFinalField += 2;
}
void methodReferences() {
@@ -2,9 +2,9 @@ package test;
class C {
void foo(ClassWithStatics c) {
ClassWithStatics.Companion.staticMethod(ClassWithStatics.staticField);
ClassWithStatics.Companion.staticMethod(ClassWithStatics.Companion.getStaticField());
c.instanceMethod();
ClassWithStatics.staticField += 2;
ClassWithStatics.Companion.setStaticNonFinalField(ClassWithStatics.Companion.getStaticNonFinalField() + 2);
}
void methodReferences() {
@@ -15,7 +15,7 @@ class C {
class D extends ClassWithStatics {
void foo() {
Companion.staticMethod(staticField);
value *= 2;
Companion.staticMethod(Companion.getStaticField());
Companion.setValue(Companion.getValue() * 2);
}
}
@@ -2,8 +2,8 @@ package test;
class C {
void foo() {
Utils.INSTANCE.foo1(Utils.staticField);
Utils.staticField += Utils.INSTANCE.foo2();
Utils.INSTANCE.foo1(Utils.INSTANCE.getStaticField());
Utils.INSTANCE.setStaticField(Utils.INSTANCE.getStaticField() + Utils.INSTANCE.foo2());
PureUtils.INSTANCE.foo1(PureUtils.INSTANCE.foo2())
}
}