View | Details | Raw Unified | Return to bug 273990 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java (-2 / +31 lines)
Lines 6200-6205 Link Here
6200
		"HELLORED", null, 
6200
		"HELLORED", null, 
6201
		JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings);
6201
		JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings);
6202
}
6202
}
6203
6203
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=273990
6204
public void test173() {
6205
	this.runNegativeTest(
6206
		new String[] {
6207
			"E.java",
6208
			"public enum E {\n" +
6209
			"	A(E.STATIK);\n" +
6210
			"	private static int STATIK = 1;\n" +
6211
			"	private E(final int i) {}\n" +
6212
			"}\n",
6213
			"E2.java",
6214
			"public enum E2 {\n" +
6215
			"	A(E2.STATIK);\n" +
6216
			"	static int STATIK = 1;\n" +
6217
			"	private E2(final int i) {}\n" +
6218
			"}\n"
6219
		},
6220
		"----------\n" + 
6221
		"1. ERROR in E.java (at line 2)\n" + 
6222
		"	A(E.STATIK);\n" + 
6223
		"	    ^^^^^^\n" + 
6224
		"Cannot reference a field before it is defined\n" + 
6225
		"----------\n" + 
6226
		"----------\n" + 
6227
		"1. ERROR in E2.java (at line 2)\n" + 
6228
		"	A(E2.STATIK);\n" + 
6229
		"	     ^^^^^^\n" + 
6230
		"Cannot reference a field before it is defined\n" + 
6231
		"----------\n"
6232
	);
6233
}
6204
}
6234
}
6205
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-1 / +1 lines)
Lines 928-934 Link Here
928
					ReferenceBinding declaringClass = fieldBinding.original().declaringClass;
928
					ReferenceBinding declaringClass = fieldBinding.original().declaringClass;
929
					SourceTypeBinding sourceType = methodScope.enclosingSourceType();
929
					SourceTypeBinding sourceType = methodScope.enclosingSourceType();
930
					// check for forward references
930
					// check for forward references
931
					if ((this.indexOfFirstFieldBinding == 1 || (fieldBinding.modifiers & ClassFileConstants.AccEnum) != 0) // enum constants are checked even when qualified
931
					if ((this.indexOfFirstFieldBinding == 1 || (fieldBinding.modifiers & ClassFileConstants.AccEnum) != 0 || (!fieldBinding.isFinal() && declaringClass.isEnum())) // enum constants are checked even when qualified
932
							&& sourceType == declaringClass
932
							&& sourceType == declaringClass
933
							&& methodScope.lastVisibleFieldID >= 0
933
							&& methodScope.lastVisibleFieldID >= 0
934
							&& fieldBinding.id >= methodScope.lastVisibleFieldID
934
							&& fieldBinding.id >= methodScope.lastVisibleFieldID

Return to bug 273990