J2K: specify type for variables with anonymous type if they have write accesses

This commit is contained in:
Natalia Ukhorskaya
2016-03-25 16:28:59 +03:00
parent 23908fb8f3
commit 470027bfd8
6 changed files with 106 additions and 2 deletions
+33
View File
@@ -25,4 +25,37 @@ class A {
field9 = null;
field10 = null;
}
interface I
private I anonymous = new I() {
};
public I anonymous2 = new I() {
};
private I anonymous3 = new I() {
};
private I iimpl = anonymous;
void testAnonymousObject(Object i) {
if (true) {
iimpl = (I) i;
}
else if (true) {
anonymous3 = (I) i;
}
I anonymousLocal1 = new I() {
};
I anonymousLocal2 = new I() {
};
I iimpl = anonymousLocal1;
if (true) {
anonymousLocal2 = (I) i;
}
}
}
+37
View File
@@ -26,4 +26,41 @@ internal class A {
field9 = null
field10 = null
}
internal interface I
private val anonymous: I = object : I {
}
var anonymous2: I = object : I {
}
private var anonymous3: I = object : I {
}
private var iimpl = anonymous
fun testAnonymousObject(i: Any) {
if (true) {
iimpl = i as I
} else if (true) {
anonymous3 = i as I
}
val anonymousLocal1: I = object : I {
}
var anonymousLocal2: I = object : I {
}
val iimpl = anonymousLocal1
if (true) {
anonymousLocal2 = i as I
}
}
}