View | Details | Raw Unified | Return to bug 165291
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-3 / +2 lines)
Lines 294-300 Link Here
294
		MethodScope methodScope = scope.methodScope();
294
		MethodScope methodScope = scope.methodScope();
295
		// check for forward references
295
		// check for forward references
296
		if (this.indexOfFirstFieldBinding == 1
296
		if (this.indexOfFirstFieldBinding == 1
297
				&& methodScope.enclosingSourceType() == fieldBinding.declaringClass
297
				&& methodScope.enclosingSourceType() == fieldBinding.original().declaringClass
298
				&& methodScope.lastVisibleFieldID >= 0
298
				&& methodScope.lastVisibleFieldID >= 0
299
				&& fieldBinding.id >= methodScope.lastVisibleFieldID
299
				&& fieldBinding.id >= methodScope.lastVisibleFieldID
300
				&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
300
				&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
Lines 999-1008 Link Here
999
					if (binding instanceof FieldBinding) {
999
					if (binding instanceof FieldBinding) {
1000
						FieldBinding fieldBinding = (FieldBinding) binding;
1000
						FieldBinding fieldBinding = (FieldBinding) binding;
1001
						MethodScope methodScope = scope.methodScope();
1001
						MethodScope methodScope = scope.methodScope();
1002
						ReferenceBinding declaringClass = fieldBinding.declaringClass;
1003
						// check for forward references
1002
						// check for forward references
1004
						if (this.indexOfFirstFieldBinding == 1
1003
						if (this.indexOfFirstFieldBinding == 1
1005
								&& methodScope.enclosingSourceType() == declaringClass
1004
								&& methodScope.enclosingSourceType() == fieldBinding.original().declaringClass
1006
								&& methodScope.lastVisibleFieldID >= 0
1005
								&& methodScope.lastVisibleFieldID >= 0
1007
								&& fieldBinding.id >= methodScope.lastVisibleFieldID
1006
								&& fieldBinding.id >= methodScope.lastVisibleFieldID
1008
								&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
1007
								&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-8 / +5 lines)
Lines 197-211 Link Here
197
			scope.problemReporter().deprecatedField(fieldBinding, this);
197
			scope.problemReporter().deprecatedField(fieldBinding, this);
198
	
198
	
199
		if ((this.bits & IsStrictlyAssigned) == 0
199
		if ((this.bits & IsStrictlyAssigned) == 0
200
			&& methodScope.enclosingSourceType() == fieldBinding.declaringClass
200
				&& methodScope.enclosingSourceType() == fieldBinding.original().declaringClass
201
			&& methodScope.lastVisibleFieldID >= 0
201
				&& methodScope.lastVisibleFieldID >= 0
202
			&& fieldBinding.id >= methodScope.lastVisibleFieldID) {
202
				&& fieldBinding.id >= methodScope.lastVisibleFieldID
203
			//if the field is static and ms is not .... then it is valid
203
				&& (!fieldBinding.isStatic() || methodScope.isStatic)) {
204
			if (!fieldBinding.isStatic() || methodScope.isStatic)
204
			scope.problemReporter().forwardReference(this, 0, methodScope.enclosingSourceType());
205
				scope.problemReporter().forwardReference(this, 0, methodScope.enclosingSourceType());
206
		}
205
		}
207
		//====================================================
208
	
209
		return fieldBinding.type;
206
		return fieldBinding.type;
210
	
207
	
211
	}
208
	}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+64 lines)
Lines 35664-35667 Link Here
35664
		},
35664
		},
35665
		"ERR");
35665
		"ERR");
35666
}
35666
}
35667
35668
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=165291
35669
public void test1085() {
35670
	this.runNegativeTest(
35671
		new String[] {
35672
			"Y.java",
35673
			"class Z {\n" + 
35674
			"        Z z1 = z1;\n" + 
35675
			"        Z[] z2 = z2;\n" + 
35676
			"}\n" + 
35677
			"public class Y<E> {\n" + 
35678
			"		E e0 = es[0];\n" + 
35679
			"		E e = e;\n" + 
35680
			"        E[] es = es;\n" + 
35681
			"		E e2 = e2.e;\n" + 
35682
			"}", // =================,
35683
		},
35684
		"----------\n" + 
35685
		"1. WARNING in Y.java (at line 2)\n" + 
35686
		"	Z z1 = z1;\n" + 
35687
		"	  ^^^^^^^\n" + 
35688
		"The assignment to variable z1 has no effect\n" + 
35689
		"----------\n" + 
35690
		"2. ERROR in Y.java (at line 2)\n" + 
35691
		"	Z z1 = z1;\n" + 
35692
		"	       ^^\n" + 
35693
		"Cannot reference a field before it is defined\n" + 
35694
		"----------\n" + 
35695
		"3. WARNING in Y.java (at line 3)\n" + 
35696
		"	Z[] z2 = z2;\n" + 
35697
		"	    ^^^^^^^\n" + 
35698
		"The assignment to variable z2 has no effect\n" + 
35699
		"----------\n" + 
35700
		"4. ERROR in Y.java (at line 3)\n" + 
35701
		"	Z[] z2 = z2;\n" + 
35702
		"	         ^^\n" + 
35703
		"Cannot reference a field before it is defined\n" + 
35704
		"----------\n" + 
35705
		"5. ERROR in Y.java (at line 6)\n" + 
35706
		"	E e0 = es[0];\n" + 
35707
		"	       ^^\n" + 
35708
		"Cannot reference a field before it is defined\n" + 
35709
		"----------\n" + 
35710
		"6. ERROR in Y.java (at line 7)\n" + 
35711
		"	E e = e;\n" + 
35712
		"	      ^\n" + 
35713
		"Cannot reference a field before it is defined\n" + 
35714
		"----------\n" + 
35715
		"7. ERROR in Y.java (at line 8)\n" + 
35716
		"	E[] es = es;\n" + 
35717
		"	         ^^\n" + 
35718
		"Cannot reference a field before it is defined\n" + 
35719
		"----------\n" + 
35720
		"8. ERROR in Y.java (at line 9)\n" + 
35721
		"	E e2 = e2.e;\n" + 
35722
		"	       ^^^^\n" + 
35723
		"Cannot reference a field before it is defined\n" + 
35724
		"----------\n" + 
35725
		"9. ERROR in Y.java (at line 9)\n" + 
35726
		"	E e2 = e2.e;\n" + 
35727
		"	       ^^^^\n" + 
35728
		"e2.e cannot be resolved or is not a field\n" + 
35729
		"----------\n");
35730
}
35667
}
35731
}

Return to bug 165291