LocalsOrMyInstanceFieldsControlFlowPolicy: disallow qualified this

According to JLS Chapter 16 qualified "this" is not considered as reference to field in definite assignment analysis
Fixes IDEA-193386 Good code is red: Variable may not have been initialized
This commit is contained in:
Tagir Valeev
2018-06-07 11:28:07 +07:00
parent a13bec1e73
commit 698afa3b24
3 changed files with 17 additions and 2 deletions
@@ -249,6 +249,6 @@ class QualifiedThis {
QualifiedThis() {
<error descr="Cannot assign a value to final variable 'x'">QualifiedThis.this.x</error> = 5;
<error descr="Variable 'x' might already have been assigned to">this.x</error> = 5;
this.x = 5;
}
}
@@ -1,5 +1,20 @@
import java.util.*;
class Test {
interface IntFunction {
int m(int i);
}
private final int idx;
private final int idx2 = Test.this.idx + 1;
private final IntFunction multiply = i -> i * Test.this.idx;
public Test(int idx) {
this.idx = idx;
}
}
class C {
interface Simplest {
void m();