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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-1 / +17 lines)
Lines 25-30 Link Here
25
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
25
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
26
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
27
import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.MissingTypeBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
29
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
29
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
31
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
Lines 551-557 Link Here
551
		if (!avoidSecondary) {
552
		if (!avoidSecondary) {
552
			scope.problemReporter().invalidField(this, this.actualReceiverType);
553
			scope.problemReporter().invalidField(this, this.actualReceiverType);
553
		}
554
		}
554
		return null;
555
		if (fieldBinding instanceof ProblemFieldBinding) {
556
			ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) fieldBinding;
557
			FieldBinding closestMatch = problemFieldBinding.closestMatch;
558
			switch(problemFieldBinding.problemId()) {
559
				case ProblemReasons.InheritedNameHidesEnclosingName :
560
				case ProblemReasons.NotVisible :
561
				case ProblemReasons.NonStaticReferenceInConstructorInvocation :
562
				case ProblemReasons.NonStaticReferenceInStaticContext :
563
					if (closestMatch != null) {
564
						fieldBinding = closestMatch;
565
					}
566
			}
567
		}
568
		if (!fieldBinding.isValidBinding()) {
569
			return null;
570
		}
555
	}
571
	}
556
	// handle indirect inheritance thru variable secondary bound
572
	// handle indirect inheritance thru variable secondary bound
557
	// receiver may receive generic cast, as part of implicit conversion
573
	// receiver may receive generic cast, as part of implicit conversion
(-)Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java (-8 / +3 lines)
Lines 12555-12576 Link Here
12555
			"}	\n",
12555
			"}	\n",
12556
		},
12556
		},
12557
		"----------\n" +
12557
		"----------\n" +
12558
		"1. WARNING in X.java (at line 3)\n" +
12558
		"1. ERROR in X.java (at line 6)\n" +
12559
		"	private int f;	\n" +
12560
		"	            ^\n" +
12561
		"The field X.f is never read locally\n" +
12562
		"----------\n" +
12563
		"2. ERROR in X.java (at line 6)\n" +
12564
		"	int y = new X().f;	\n" +
12559
		"	int y = new X().f;	\n" +
12565
		"	                ^\n" +
12560
		"	                ^\n" +
12566
		"The field X.f is not visible\n" +
12561
		"The field X.f is not visible\n" +
12567
		"----------\n" +
12562
		"----------\n" +
12568
		"3. ERROR in X.java (at line 7)\n" +
12563
		"2. ERROR in X.java (at line 7)\n" +
12569
		"	X.M xm = new X().new M();	\n" +
12564
		"	X.M xm = new X().new M();	\n" +
12570
		"	^^^\n" +
12565
		"	^^^\n" +
12571
		"The type X.M is not visible\n" +
12566
		"The type X.M is not visible\n" +
12572
		"----------\n" +
12567
		"----------\n" +
12573
		"4. ERROR in X.java (at line 7)\n" +
12568
		"3. ERROR in X.java (at line 7)\n" +
12574
		"	X.M xm = new X().new M();	\n" +
12569
		"	X.M xm = new X().new M();	\n" +
12575
		"	                     ^\n" +
12570
		"	                     ^\n" +
12576
		"The type X.M is not visible\n" +
12571
		"The type X.M is not visible\n" +
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-46 / +51 lines)
Lines 14397-14448 Link Here
14397
				"   } \n" +
14397
				"   } \n" +
14398
				"}\n"
14398
				"}\n"
14399
			},
14399
			},
14400
			"----------\n" +
14400
			"----------\n" + 
14401
			"1. WARNING in test\\Foo.java (at line 4)\n" +
14401
			"1. WARNING in test\\Foo.java (at line 4)\n" + 
14402
			"	private R dosomething(){ return s; } \n" +
14402
			"	private R dosomething(){ return s; } \n" + 
14403
			"	          ^^^^^^^^^^^^^\n" +
14403
			"	          ^^^^^^^^^^^^^\n" + 
14404
			"The method dosomething() from the type Foo<R> is never used locally\n" +
14404
			"The method dosomething() from the type Foo<R> is never used locally\n" + 
14405
			"----------\n" +
14405
			"----------\n" + 
14406
			"2. WARNING in test\\Foo.java (at line 5)\n" +
14406
			"2. WARNING in test\\Foo.java (at line 5)\n" + 
14407
			"	private class Bar {} \n" +
14407
			"	private class Bar {} \n" + 
14408
			"	              ^^^\n" +
14408
			"	              ^^^\n" + 
14409
			"The type Foo<R>.Bar is never used locally\n" +
14409
			"The type Foo<R>.Bar is never used locally\n" + 
14410
			"----------\n" +
14410
			"----------\n" + 
14411
			"----------\n" +
14411
			"----------\n" + 
14412
			"1. ERROR in test02\\FooBar.java (at line 6)\n" +
14412
			"1. ERROR in test02\\FooBar.java (at line 6)\n" + 
14413
			"	f.s = \"foo\"; \n" +
14413
			"	f.s = \"foo\"; \n" + 
14414
			"	  ^\n" +
14414
			"	  ^\n" + 
14415
			"The field Foo<String>.s is not visible\n" +
14415
			"The field Foo<String>.s is not visible\n" + 
14416
			"----------\n" +
14416
			"----------\n" + 
14417
			"2. ERROR in test02\\FooBar.java (at line 7)\n" +
14417
			"2. ERROR in test02\\FooBar.java (at line 7)\n" + 
14418
			"	this.s = \"foo\";\n" +
14418
			"	this.s = \"foo\";\n" + 
14419
			"	     ^\n" +
14419
			"	     ^\n" + 
14420
			"The field Foo<R>.s is not visible\n" +
14420
			"The field Foo<R>.s is not visible\n" + 
14421
			"----------\n" +
14421
			"----------\n" + 
14422
			"3. ERROR in test02\\FooBar.java (at line 8)\n" +
14422
			"3. ERROR in test02\\FooBar.java (at line 7)\n" + 
14423
			"	f.dosomething(); \n" +
14423
			"	this.s = \"foo\";\n" + 
14424
			"	  ^^^^^^^^^^^\n" +
14424
			"	         ^^^^^\n" + 
14425
			"The method dosomething() from the type Foo<String> is not visible\n" +
14425
			"Type mismatch: cannot convert from String to R\n" + 
14426
			"----------\n" +
14426
			"----------\n" + 
14427
			"4. ERROR in test02\\FooBar.java (at line 9)\n" +
14427
			"4. ERROR in test02\\FooBar.java (at line 8)\n" + 
14428
			"	this.dosomething();  \n" +
14428
			"	f.dosomething(); \n" + 
14429
			"	     ^^^^^^^^^^^\n" +
14429
			"	  ^^^^^^^^^^^\n" + 
14430
			"The method dosomething() from the type Foo<R> is not visible\n" +
14430
			"The method dosomething() from the type Foo<String> is not visible\n" + 
14431
			"----------\n" +
14431
			"----------\n" + 
14432
			"5. ERROR in test02\\FooBar.java (at line 10)\n" +
14432
			"5. ERROR in test02\\FooBar.java (at line 9)\n" + 
14433
			"	Bar b1; \n" +
14433
			"	this.dosomething();  \n" + 
14434
			"	^^^\n" +
14434
			"	     ^^^^^^^^^^^\n" + 
14435
			"The type Bar is not visible\n" +
14435
			"The method dosomething() from the type Foo<R> is not visible\n" + 
14436
			"----------\n" +
14436
			"----------\n" + 
14437
			"6. ERROR in test02\\FooBar.java (at line 11)\n" +
14437
			"6. ERROR in test02\\FooBar.java (at line 10)\n" + 
14438
			"	FooBar<String>.Bar b2; \n" +
14438
			"	Bar b1; \n" + 
14439
			"	^^^^^^^^^^^^^^^^^^\n" +
14439
			"	^^^\n" + 
14440
			"The type FooBar.Bar is not visible\n" +
14440
			"The type Bar is not visible\n" + 
14441
			"----------\n" +
14441
			"----------\n" + 
14442
			"7. ERROR in test02\\FooBar.java (at line 12)\n" +
14442
			"7. ERROR in test02\\FooBar.java (at line 11)\n" + 
14443
			"	Foo<String>.Bar b3; \n" +
14443
			"	FooBar<String>.Bar b2; \n" + 
14444
			"	^^^^^^^^^^^^^^^\n" +
14444
			"	^^^^^^^^^^^^^^^^^^\n" + 
14445
			"The type Foo.Bar is not visible\n" +
14445
			"The type FooBar.Bar is not visible\n" + 
14446
			"----------\n" + 
14447
			"8. ERROR in test02\\FooBar.java (at line 12)\n" + 
14448
			"	Foo<String>.Bar b3; \n" + 
14449
			"	^^^^^^^^^^^^^^^\n" + 
14450
			"The type Foo.Bar is not visible\n" + 
14446
			"----------\n");
14451
			"----------\n");
14447
	}
14452
	}
14448
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=81594
14453
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=81594
(-)src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java (-12 / +7 lines)
Lines 216-230 Link Here
216
			"}"
216
			"}"
217
		},
217
		},
218
		"----------\n" +
218
		"----------\n" +
219
		"1. WARNING in p1\\A.java (at line 3)\n" +
219
		"1. ERROR in p1\\A.java (at line 7)\n" +
220
		"	private static String success = \"SUCCESS\";	\n" +
221
		"	                      ^^^^^^^\n" +
222
		"The field A.success is never read locally\n" +
223
		"----------\n" +
224
		"2. ERROR in p1\\A.java (at line 7)\n" +
225
		"	public void aTask() {System.out.println(this.success);}\n" +
220
		"	public void aTask() {System.out.println(this.success);}\n" +
226
		"	                                             ^^^^^^^\n" +
221
		"	                                             ^^^^^^^\n" +
227
		"The field A.success is not visible\n" +
222
		"The field A.success is not visible\n" +
223
		"----------\n" +
224
		"2. WARNING in p1\\A.java (at line 7)\n" +
225
		"	public void aTask() {System.out.println(this.success);}\n" +
226
		"	                                             ^^^^^^^\n" +
227
		"The static field A.success should be accessed in a static way\n" +
228
		"----------\n");
228
		"----------\n");
229
}
229
}
230
/**
230
/**
Lines 308-319 Link Here
308
			"}"
308
			"}"
309
		},
309
		},
310
		"----------\n" +
310
		"----------\n" +
311
		"1. WARNING in p1\\A.java (at line 3)\n" +
311
		"1. ERROR in p1\\A.java (at line 7)\n" +
312
		"	private String success = \"SUCCESS\";			\n" +
313
		"	               ^^^^^^^\n" +
314
		"The field A.success is never read locally\n" +
315
		"----------\n" +
316
		"2. ERROR in p1\\A.java (at line 7)\n" +
317
		"	public void aTask() {System.out.println(this.success);}\n" +
312
		"	public void aTask() {System.out.println(this.success);}\n" +
318
		"	                                             ^^^^^^^\n" +
313
		"	                                             ^^^^^^^\n" +
319
		"The field A.success is not visible\n" +
314
		"The field A.success is not visible\n" +
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-1 / +3 lines)
Lines 122-128 Link Here
122
	static {
122
	static {
123
//		TESTS_NAMES = new String[] {"test0602"};
123
//		TESTS_NAMES = new String[] {"test0602"};
124
//		TESTS_RANGE = new int[] { 713, -1 };
124
//		TESTS_RANGE = new int[] { 713, -1 };
125
//		TESTS_NUMBERS =  new int[] { 718 };
125
//		TESTS_NUMBERS =  new int[] { 653 };
126
	}
126
	}
127
	public static Test suite() {
127
	public static Test suite() {
128
		return buildModelTestSuite(ASTConverterTestAST3_2.class);
128
		return buildModelTestSuite(ASTConverterTestAST3_2.class);
Lines 8067-8072 Link Here
8067
		FieldAccess fieldAccess = (FieldAccess) expression;
8067
		FieldAccess fieldAccess = (FieldAccess) expression;
8068
		IVariableBinding variableBinding = fieldAccess.resolveFieldBinding();
8068
		IVariableBinding variableBinding = fieldAccess.resolveFieldBinding();
8069
		assertNotNull("No variable binding", variableBinding);
8069
		assertNotNull("No variable binding", variableBinding);
8070
		IMethodBinding resolveMethodBinding = invocation.resolveMethodBinding();
8071
		assertNotNull("No binding", resolveMethodBinding);
8070
	}
8072
	}
8071
8073
8072
8074

Return to bug 150409