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

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java (+6 lines)
Lines 481-486 Link Here
481
		}
481
		}
482
		if ((binding = findMemberType(nextName, referenceBinding)) == null) {
482
		if ((binding = findMemberType(nextName, referenceBinding)) == null) {
483
			if ((mask & Binding.FIELD) != 0) {
483
			if ((mask & Binding.FIELD) != 0) {
484
				return new ProblemFieldBinding(
485
						null,
486
						referenceBinding,
487
						nextName,
488
						ProblemReasons.NotFound);
489
			} else if ((mask & Binding.VARIABLE) != 0) {
484
				return new ProblemBinding(
490
				return new ProblemBinding(
485
					CharOperation.subarray(compoundName, 0, currentIndex),
491
					CharOperation.subarray(compoundName, 0, currentIndex),
486
					referenceBinding,
492
					referenceBinding,
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-2 / +8 lines)
Lines 3199-3206 Link Here
3199
						nameRef.sourceEnd);
3199
						nameRef.sourceEnd);
3200
					return;
3200
					return;
3201
			}
3201
			}
3202
			id = IProblem.UndefinedField;
3202
			String[] arguments = new String[] {new String(field.readableName())};
3203
			break;
3203
			this.handle(
3204
					id,
3205
					arguments,
3206
					arguments,
3207
					nodeSourceStart(field, nameRef),
3208
					nodeSourceEnd(field, nameRef));
3209
			return;
3204
		case ProblemReasons.NotVisible :
3210
		case ProblemReasons.NotVisible :
3205
			char[] name = field.readableName();
3211
			char[] name = field.readableName();
3206
			name = CharOperation.lastSegment(name, '.');
3212
			name = CharOperation.lastSegment(name, '.');
(-)Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java (-28 / +5 lines)
Lines 4995-5005 Link Here
4995
			"  }\n" +
4995
			"  }\n" +
4996
			"}",
4996
			"}",
4997
		},
4997
		},
4998
		"----------\n" +
4998
		"----------\n" + 
4999
		"1. ERROR in p\\O.java (at line 4)\n" +
4999
		"1. ERROR in p\\O.java (at line 4)\n" + 
5000
		"	System.out.println(Object.FOO);\n" +
5000
		"	System.out.println(Object.FOO);\n" + 
5001
		"	                   ^^^^^^^^^^\n" +
5001
		"	                          ^^^\n" + 
5002
		"Object.FOO cannot be resolved to a variable\n" +
5002
		"FOO cannot be resolved or is not a field\n" + 
5003
		"----------\n"
5003
		"----------\n"
5004
	);
5004
	);
5005
}
5005
}
Lines 6052-6080 Link Here
6052
		"----------\n"
6052
		"----------\n"
6053
	);
6053
	);
6054
}
6054
}
6055
public void test159() {
6056
	this.runNegativeTest(
6057
		new String[] {
6058
			"p/A9.java",
6059
			"package p;\n" +
6060
			"/**\n" +
6061
			" * 1FA4ETM\n" +
6062
			" */\n" +
6063
			" \n" +
6064
			"class A9 {\n" +
6065
			"  public static void main(String[] args) {\n" +
6066
			"    System.out.println(Object.FOO); // error Object.FOO undefined\n" +
6067
			"  }\n" +
6068
			"}",
6069
		},
6070
		"----------\n" +
6071
		"1. ERROR in p\\A9.java (at line 8)\n" +
6072
		"	System.out.println(Object.FOO); // error Object.FOO undefined\n" +
6073
		"	                   ^^^^^^^^^^\n" +
6074
		"Object.FOO cannot be resolved to a variable\n" +
6075
		"----------\n"
6076
	);
6077
}
6078
public void test161() {
6055
public void test161() {
6079
	this.runNegativeTest(
6056
	this.runNegativeTest(
6080
		new String[] {
6057
		new String[] {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-52 / +52 lines)
Lines 9204-9211 Link Here
9204
		"----------\n" +  /* expectedErrOutputString */
9204
		"----------\n" +  /* expectedErrOutputString */
9205
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 3)\n" +
9205
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 3)\n" +
9206
		"	System.out.println(X.CONST);\n" +
9206
		"	System.out.println(X.CONST);\n" +
9207
		"	                   ^^^^^^^\n" +
9207
		"	                     ^^^^^\n" +
9208
		"X.CONST cannot be resolved to a variable\n" +
9208
		"CONST cannot be resolved or is not a field\n" +
9209
		"----------\n" +
9209
		"----------\n" +
9210
		"1 problem (1 error)",
9210
		"1 problem (1 error)",
9211
		false /* shouldFlushOutputDirectory */,
9211
		false /* shouldFlushOutputDirectory */,
Lines 9447-9458 Link Here
9447
		sourceFilePath /* commandLine */
9447
		sourceFilePath /* commandLine */
9448
		+ " -proc:none " + commonOptions,
9448
		+ " -proc:none " + commonOptions,
9449
		"" /* expectedOutOutputString */,
9449
		"" /* expectedOutOutputString */,
9450
		"----------\n" + /* expectedErrOutputString */
9450
		"----------\n" + 
9451
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 3)\n" +
9451
		"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/Y.java (at line 3)\n" + 
9452
		"	System.out.println(X.CONST);\n" +
9452
		"	System.out.println(X.CONST);\n" + 
9453
		"	                   ^^^^^^^\n" +
9453
		"	                     ^^^^^\n" + 
9454
		"X.CONST cannot be resolved to a variable\n" +
9454
		"CONST cannot be resolved or is not a field\n" + 
9455
		"----------\n" +
9455
		"----------\n" + 
9456
		"1 problem (1 error)",
9456
		"1 problem (1 error)",
9457
		false /* shouldFlushOutputDirectory */,
9457
		false /* shouldFlushOutputDirectory */,
9458
		null /* progress */);
9458
		null /* progress */);
Lines 9729-9789 Link Here
9729
public void test241_jar_ref_in_jar(){
9729
public void test241_jar_ref_in_jar(){
9730
	createCascadedJars();
9730
	createCascadedJars();
9731
	this.runNegativeTest(
9731
	this.runNegativeTest(
9732
		new String[] {
9732
			new String[] {
9733
			"src/p/X.java",
9733
					"src/p/X.java",
9734
			"package p;\n" +
9734
					"package p;\n" +
9735
			"/** */\n" +
9735
					"/** */\n" +
9736
			"public class X {\n" +
9736
					"public class X {\n" +
9737
			"  int i = R.R2;\n" +
9737
					"  int i = R.R2;\n" +
9738
			"  int j = R.R3;\n" +
9738
					"  int j = R.R3;\n" +
9739
			"}",
9739
					"}",
9740
		},
9740
			},
9741
	  "\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
9741
			"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
9742
			+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar\""
9742
			+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar\""
9743
			+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar\""
9743
			+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar\""
9744
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
9744
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
9745
	  + " -1.5 -g -preserveAllLocals"
9745
			+ " -1.5 -g -preserveAllLocals"
9746
	  + " -proceedOnError -referenceInfo"
9746
			+ " -proceedOnError -referenceInfo"
9747
	  + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
9747
			+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
9748
	  "",
9748
			"",
9749
	  "----------\n" +
9749
			"----------\n" + 
9750
	  "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" +
9750
			"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + 
9751
	  "	int j = R.R3;\n" +
9751
			"	int j = R.R3;\n" + 
9752
	  "	        ^^^^\n" +
9752
			"	          ^^\n" + 
9753
	  "R.R3 cannot be resolved to a variable\n" +
9753
			"R3 cannot be resolved or is not a field\n" + 
9754
	  "----------\n" +
9754
			"----------\n" + 
9755
	  "1 problem (1 error)",
9755
			"1 problem (1 error)",
9756
	  true);
9756
			true);
9757
}
9757
}
9758
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
9758
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
9759
// using only links, we adopt a depth first algorithm
9759
// using only links, we adopt a depth first algorithm
9760
public void test242_jar_ref_in_jar(){
9760
public void test242_jar_ref_in_jar(){
9761
	createCascadedJars();
9761
	createCascadedJars();
9762
	this.runNegativeTest(
9762
	this.runNegativeTest(
9763
		new String[] {
9763
			new String[] {
9764
			"src/p/X.java",
9764
					"src/p/X.java",
9765
			"package p;\n" +
9765
					"package p;\n" +
9766
			"/** */\n" +
9766
					"/** */\n" +
9767
			"public class X {\n" +
9767
					"public class X {\n" +
9768
			"  int i = R.R2;\n" +
9768
					"  int i = R.R2;\n" +
9769
			"  int j = R.R3;\n" +
9769
					"  int j = R.R3;\n" +
9770
			"}",
9770
					"}",
9771
		},
9771
			},
9772
	  "\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
9772
			"\"" + OUTPUT_DIR +  File.separator + "src/p/X.java\""
9773
			+ " -cp \"" + LIB_DIR + File.separator + "lib4.jar\""
9773
			+ " -cp \"" + LIB_DIR + File.separator + "lib4.jar\""
9774
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
9774
			+ " -sourcepath \"" + OUTPUT_DIR +  File.separator + "src\""
9775
	  + " -1.5 -g -preserveAllLocals"
9775
			+ " -1.5 -g -preserveAllLocals"
9776
	  + " -proceedOnError -referenceInfo"
9776
			+ " -proceedOnError -referenceInfo"
9777
	  + " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
9777
			+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ",
9778
	  "",
9778
			"",
9779
	  "----------\n" +
9779
			"----------\n" + 
9780
	  "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" +
9780
			"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + 
9781
	  "	int j = R.R3;\n" +
9781
			"	int j = R.R3;\n" + 
9782
	  "	        ^^^^\n" +
9782
			"	          ^^\n" + 
9783
	  "R.R3 cannot be resolved to a variable\n" +
9783
			"R3 cannot be resolved or is not a field\n" + 
9784
	  "----------\n" +
9784
			"----------\n" + 
9785
	  "1 problem (1 error)",
9785
			"1 problem (1 error)",
9786
	  true);
9786
			true);
9787
}
9787
}
9788
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
9788
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
9789
// managing subdirectories and .. properly
9789
// managing subdirectories and .. properly
(-)src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java (-1 / +31 lines)
Lines 19-25 Link Here
19
public class FieldAccessTest extends AbstractRegressionTest {
19
public class FieldAccessTest extends AbstractRegressionTest {
20
	static {
20
	static {
21
//		TESTS_NAMES = new String[] { "test000" };
21
//		TESTS_NAMES = new String[] { "test000" };
22
//		TESTS_NUMBERS = new int[] { 21 };
22
//		TESTS_NUMBERS = new int[] { 22 };
23
//		TESTS_RANGE = new int[] { 21, 50 };
23
//		TESTS_RANGE = new int[] { 21, 50 };
24
	}
24
	}
25
25
Lines 649-654 Link Here
649
		true,
649
		true,
650
		options);
650
		options);
651
}
651
}
652
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=303830
653
public void test022() {
654
	this.runNegativeTest(
655
		new String[] {
656
			"X.java",
657
			"public class X {\n" + 
658
			"	static int NEW_FIELD;\n" + 
659
			"}",
660
			"Y.java",
661
			"public class Y {\n" + 
662
			"	void foo() {\n" + 
663
			"		int i = X.OLD_FIELD;\n" + 
664
			"	}\n" + 
665
			"	void bar() {\n" + 
666
			"		int j = X.OLD_FIELD;\n" + 
667
			"	}\n" + 
668
			"}"
669
		},
670
		"----------\n" + 
671
		"1. ERROR in Y.java (at line 3)\n" + 
672
		"	int i = X.OLD_FIELD;\n" + 
673
		"	          ^^^^^^^^^\n" + 
674
		"OLD_FIELD cannot be resolved or is not a field\n" + 
675
		"----------\n" + 
676
		"2. ERROR in Y.java (at line 6)\n" + 
677
		"	int j = X.OLD_FIELD;\n" + 
678
		"	          ^^^^^^^^^\n" + 
679
		"OLD_FIELD cannot be resolved or is not a field\n" + 
680
		"----------\n");
681
}
652
public static Class testClass() {
682
public static Class testClass() {
653
	return FieldAccessTest.class;
683
	return FieldAccessTest.class;
654
}
684
}
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-4 / +3 lines)
Lines 7685-7695 Link Here
7685
				true);
7685
				true);
7686
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7686
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7687
			CompilationUnit unit = (CompilationUnit) node;
7687
			CompilationUnit unit = (CompilationUnit) node;
7688
			assertProblemsSize(
7688
			assertEquals(
7689
					unit,
7689
					"Wrong problem size",
7690
					2,
7690
					2,
7691
					"Object.equ cannot be resolved to a variable\n" +
7691
					unit.getProblems().length);
7692
					"Syntax error, insert \"AssignmentOperator Expression\" to complete Expression");
7693
			node = getASTNode(unit, 0, 0);
7692
			node = getASTNode(unit, 0, 0);
7694
			assertEquals("Not a field declaration statement", ASTNode.INITIALIZER, node.getNodeType());
7693
			assertEquals("Not a field declaration statement", ASTNode.INITIALIZER, node.getNodeType());
7695
			Initializer initializer = (Initializer) node;
7694
			Initializer initializer = (Initializer) node;

Return to bug 182459