### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v retrieving revision 1.99 diff -u -r1.99 QualifiedAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 18 Jan 2010 12:40:18 -0000 1.99 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 22 Jun 2010 06:26:10 -0000 @@ -227,6 +227,7 @@ this.constant = Constant.NotAConstant; TypeBinding enclosingInstanceType = null; + ReferenceBinding enclosingInstanceReference = null; TypeBinding receiverType = null; boolean hasError = false; boolean enclosingInstanceContainsCast = false; @@ -247,6 +248,14 @@ } else if (this.type instanceof QualifiedTypeReference) { scope.problemReporter().illegalUsageOfQualifiedTypeReference((QualifiedTypeReference)this.type); hasError = true; + } else if (!(enclosingInstanceReference = (ReferenceBinding) enclosingInstanceType).canBeSeenBy((scope.getCurrentPackage()))) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=317212 + enclosingInstanceType = new ProblemReferenceBinding( + enclosingInstanceReference.compoundName, + enclosingInstanceReference, + ProblemReasons.NotVisible); + scope.problemReporter().invalidType(this.enclosingInstance, enclosingInstanceType); + hasError = true; } else { receiverType = ((SingleTypeReference) this.type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType); if (receiverType != null && enclosingInstanceContainsCast) { #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java,v retrieving revision 1.83 diff -u -r1.83 LookupTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 9 Mar 2010 04:28:15 -0000 1.83 +++ src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 22 Jun 2010 06:26:40 -0000 @@ -35,6 +35,10 @@ public static Test suite() { return buildAllCompliancesTestSuite(testClass()); } + +static { +// TESTS_NAMES = new String [] { "test096" }; +} /** * Non-static member class */ @@ -3097,6 +3101,81 @@ "The type p1.B1 is not visible\n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id= 317212 +public void test096() { + this.runNegativeTest( + new String[] { + "p0/B.java",//------------------------------ + "package p0;\n" + + "public class B {\n" + + " public static A m() {\n" + + " return new A();\n" + + " }\n" + + "}\n" + + "class A {\n" + + " public class M {\n" + + " public M() {}\n" + + " }\n" + + "}\n", + "p1/C.java",//------------------------------ + "package p1;\n" + + "import p0.B;\n" + + "public class C {\n" + + " public static void main(String[] args) {\n" + + " B.m().new M();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in p1\\C.java (at line 5)\n" + + " B.m().new M();\n" + + " ^^^^^\n" + + "The type p0.A is not visible\n" + + "----------\n"); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id= 317212 +public void test097() { + this.runNegativeTest( + new String[] { + "B.java",//------------------------------ + "public class B {\n" + + " public static A m() {\n" + + " return new B().new A();\n" + + " }\n" + + " private class A {\n" + + " public class M {\n" + + " public M() {}\n" + + " }\n" + + " }\n" + + "}\n" + + "class C {\n" + + " public static void main(String[] args) {\n" + + " B.m().new M();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in B.java (at line 3)\n" + + " return new B().new A();\n" + + " ^^^^^^^^^^^^^^^\n" + + "Access to enclosing constructor B.A() is emulated by a synthetic accessor method\n" + + "----------\n" + + "2. WARNING in B.java (at line 6)\n" + + " public class M {\n" + + " ^\n" + + "The type B.A.M is never used locally\n" + + "----------\n" + + "3. WARNING in B.java (at line 7)\n" + + " public M() {}\n" + + " ^^^\n" + + "The constructor B.A.M() is never used locally\n" + + "----------\n" + + "4. ERROR in B.java (at line 13)\n" + + " B.m().new M();\n" + + " ^^^^^\n" + + "The type B$A is not visible\n" + + "----------\n"); +} public static Class testClass() { return LookupTest.class; } }