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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java (-2 / +3 lines)
Lines 149-156 Link Here
149
		checkHiding: {
149
		checkHiding: {
150
			SourceTypeBinding declaringType = classScope.enclosingSourceType();
150
			SourceTypeBinding declaringType = classScope.enclosingSourceType();
151
			checkHidingSuperField: {
151
			checkHidingSuperField: {
152
				if (declaringType.superclass == null) break checkHidingSuperField;
152
				ReferenceBinding superClass = declaringType.superclass;
153
				FieldBinding existingVariable = classScope.findField(declaringType.superclass, this.name, this,  false /*do not resolve hidden field*/);
153
				if (superClass == null) break checkHidingSuperField;
154
				FieldBinding existingVariable = superClass.getField(this.name, false);
154
				if (existingVariable == null) break checkHidingSuperField; // keep checking outer scenario
155
				if (existingVariable == null) break checkHidingSuperField; // keep checking outer scenario
155
				if (!existingVariable.isValidBinding())  break checkHidingSuperField; // keep checking outer scenario
156
				if (!existingVariable.isValidBinding())  break checkHidingSuperField; // keep checking outer scenario
156
				if (existingVariable.original() == this.binding) break checkHidingSuperField; // keep checking outer scenario
157
				if (existingVariable.original() == this.binding) break checkHidingSuperField; // keep checking outer scenario
(-)src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java (+23 lines)
Lines 679-684 Link Here
679
		"OLD_FIELD cannot be resolved or is not a field\n" + 
679
		"OLD_FIELD cannot be resolved or is not a field\n" + 
680
		"----------\n");
680
		"----------\n");
681
}
681
}
682
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318171
683
public void test023() {
684
	this.runNegativeTest(
685
		new String[] {
686
			"p1/A.java",
687
			"package p1;\n" +
688
			"public abstract class A {\n" +
689
			"    protected int field;\n" +
690
			"}\n",
691
			"p2/B.java",
692
			"package p2;\n" +
693
			"import p1.A;\n" +
694
			"public abstract class B extends A {\n" +
695
			"    protected int field;\n" +
696
			"}\n"
697
		},
698
		"----------\n" + 
699
		"1. WARNING in p2\\B.java (at line 4)\n" + 
700
		"	protected int field;\n" + 
701
		"	              ^^^^^\n" + 
702
		"The field B.field is hiding a field from type A\n" + 
703
		"----------\n");
704
}
682
public static Class testClass() {
705
public static Class testClass() {
683
	return FieldAccessTest.class;
706
	return FieldAccessTest.class;
684
}
707
}

Return to bug 318171