[java] UnnecessaryFullyQualifiedName - improve test case

This commit is contained in:
Andreas Dangel 2024-11-22 09:46:35 +01:00
parent 918684c154
commit 3e9e128aa7
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3

View File

@ -1129,9 +1129,7 @@ public class Foo {
<description>#5263 FP when forward reference is illegal</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public enum EnumX {
VALUE_X(EnumX.X); // MUST qualify the name or the file won't compile
static final String X = "X";
@ -1152,16 +1150,13 @@ public class Foo {
<description>#5263 FP when forward reference is illegal (class)</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class EnumX {
static final String Y = EnumX.X; // MUST qualify the name or the file won't compile
public class ClassX {
static final String Y = ClassX.X; // MUST qualify the name or the file won't compile
static final String X = "X";
private final String v;
EnumX(final String v) {
ClassX(final String v) {
this.v = v;
}
@ -1174,27 +1169,25 @@ public class Foo {
<test-code>
<description>#5263 not forward references</description>
<expected-problems>5</expected-problems>
<expected-linenumbers>3,6,9,13,17</expected-linenumbers>
<code><![CDATA[
public class EnumX {
public class ClassX {
static final Object Y = new Object() {
String q = EnumX.X; // not FWR
String q = ClassX.X; // not FWR
};
private final String v = ClassX.X; // not FWR bc not static
private final String v = EnumX.X; // not FWR bc not static
EnumX() {
this.v = EnumX.X; // not FWR
ClassX() {
this.v = ClassX.X; // not FWR
}
void foo() {
System.out.println(EnumX.X); // not FWR
System.out.println(ClassX.X); // not FWR
}
static void bar() {
System.out.println(EnumX.X); // not FWR
System.out.println(ClassX.X); // not FWR
}
static final String X = "X";