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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java (+26 lines)
Lines 1872-1875 Link Here
1872
			"The local variable i may not have been initialized\n" + 
1872
			"The local variable i may not have been initialized\n" + 
1873
			"----------\n");		
1873
			"----------\n");		
1874
	}
1874
	}
1875
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=187329
1876
	public void test050() {
1877
		this.runConformTest(
1878
			new String[] {
1879
				"p/A.java",
1880
				"package p;\n" +
1881
				"import static p.B.bar3;\n" + 
1882
				"public class A { int a = bar3; }" ,
1883
				"p/B.java",
1884
				"package p;\n" +
1885
				"import static p.Util.someStaticMethod;\n" +
1886
				"public class B {\n" +
1887
				"	static final int bar = someStaticMethod();\n" +
1888
				"	static final int bar2 = someStaticMethod();\n" +
1889
				"	static final int bar3 = someStaticMethod();\n" +
1890
				"}" ,
1891
				"p/C.java",
1892
				"package p;\n" +
1893
				"import static p.B.bar;\n" + 
1894
				"public class C { int c = bar; }" ,
1895
				"p/Util.java",
1896
				"package p;\n" +
1897
				"class Util { static int someStaticMethod() { return 0; } }"
1898
			},
1899
			"");		
1900
	}
1875
}
1901
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (+3 lines)
Lines 293-298 Link Here
293
	if (referenceContext.imports == null) {
293
	if (referenceContext.imports == null) {
294
		this.typeOrPackageCache = new HashtableOfObject(1);
294
		this.typeOrPackageCache = new HashtableOfObject(1);
295
		return;
295
		return;
296
	} else if (this.typeOrPackageCache != null) {
297
		// can be called when a field constant is resolved before static imports
298
		return;
296
	}
299
	}
297
300
298
	// collect the top level type names if a single type import exists
301
	// collect the top level type names if a single type import exists
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (+1 lines)
Lines 1877-1882 Link Here
1877
1877
1878
			// at this point the scope is a compilation unit scope & need to check for imported static methods
1878
			// at this point the scope is a compilation unit scope & need to check for imported static methods
1879
			CompilationUnitScope unitScope = (CompilationUnitScope) scope;
1879
			CompilationUnitScope unitScope = (CompilationUnitScope) scope;
1880
			unitScope.faultInImports(); // field constants can cause static imports to be accessed before they're resolved 
1880
			ImportBinding[] imports = unitScope.imports;
1881
			ImportBinding[] imports = unitScope.imports;
1881
			if (imports != null) {
1882
			if (imports != null) {
1882
				ObjectVector visible = null;
1883
				ObjectVector visible = null;

Return to bug 187329