dfa: support outer class fields access with qualified this

more test samples
This commit is contained in:
peter
2015-01-14 21:20:19 +01:00
parent 8658b30dde
commit e497f0221c
3 changed files with 44 additions and 14 deletions
@@ -1,6 +1,9 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.Override;
import java.lang.Runnable;
class TestInspection {
private static class StringWrapper {
@@ -45,17 +48,3 @@ class TestInspection {
}
}
class WithInner {
@Nullable Object o;
{
new Runnable() {
@Override
public void run() {
if (WithInner.this.o != null) {
System.out.println(WithInner.this.o.toString());
}
}
};
}
}
@@ -0,0 +1,40 @@
import org.jetbrains.annotations.Nullable;
class WithInner extends SomeSuper {
@Nullable Object o;
{
new Runnable() {
@Override
public void run() {
if (WithInner.this.o != null) {
System.out.println(WithInner.this.o.toString());
}
}
};
}
}
class SomeSuper {
@Nullable Object o2;
}
class Impl1 extends SomeSuper {
class Impl2 extends SomeSuper {
{
new Runnable() {
@Override
public void run() {
if (Impl1.this.o2 != null) {
System.out.println(<warning descr="Method invocation 'Impl2.this.o2.hashCode()' may produce 'java.lang.NullPointerException'">Impl2.this.o2.hashCode()</warning>);
}
}
};
SomeSuper s = Impl1.this;
if (s.o2 != null) {
System.out.println(s.o2.toString());
}
}
}
}
@@ -107,6 +107,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testAccessorPlusMutator() throws Throwable { doTest(); }
public void testClosureVariableField() throws Throwable { doTest(); }
public void testOptionalThis() { doTest(); }
public void testQualifiedThis() { doTest(); }
public void testAssigningNullableToNotNull() throws Throwable { doTest(); }
public void testAssigningUnknownToNullable() throws Throwable { doTest(); }