Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/FieldRewrittenInInner.java
Tagir Valeev 23063d2a84 DFA control flow: do not leak this for nested class constructor
GitOrigin-RevId: a5c8e571dac99819b9f058db753f3a41e1025aac
2019-07-11 13:51:26 +03:00

55 lines
1.0 KiB
Java

class Tester
{
public static void main(String[] args)
{
new Tester();
}
private boolean flag;
private Tester()
{
// qualified ctor: should drop locality
this.new Inner();
if (flag)
System.err.println("Is true.");
else
System.err.println("Is false");
}
private Tester(boolean b)
{
// unqualified ctor: should drop locality
new Inner();
if (flag)
System.err.println("Is true.");
else
System.err.println("Is false");
}
private Tester(int i)
{
// nested class: should not drop locality ('this' is not leaked)
new Nested();
if (<warning descr="Condition 'flag' is always 'false'">flag</warning>)
System.err.println("Is true.");
else
System.err.println("Is false");
}
class Inner
{
Inner()
{
flag = true;
}
}
static class Nested
{
Nested()
{
<error descr="Non-static field 'flag' cannot be referenced from a static context">flag</error> = true; // cannot access flag
}
}
}