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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (+9 lines)
Lines 227-232 Link Here
227
227
228
		this.constant = Constant.NotAConstant;
228
		this.constant = Constant.NotAConstant;
229
		TypeBinding enclosingInstanceType = null;
229
		TypeBinding enclosingInstanceType = null;
230
		ReferenceBinding enclosingInstanceReference = null;
230
		TypeBinding receiverType = null;
231
		TypeBinding receiverType = null;
231
		boolean hasError = false;
232
		boolean hasError = false;
232
		boolean enclosingInstanceContainsCast = false;
233
		boolean enclosingInstanceContainsCast = false;
Lines 247-252 Link Here
247
			} else if (this.type instanceof QualifiedTypeReference) {
248
			} else if (this.type instanceof QualifiedTypeReference) {
248
				scope.problemReporter().illegalUsageOfQualifiedTypeReference((QualifiedTypeReference)this.type);
249
				scope.problemReporter().illegalUsageOfQualifiedTypeReference((QualifiedTypeReference)this.type);
249
				hasError = true;
250
				hasError = true;
251
			} else if (!(enclosingInstanceReference = (ReferenceBinding) enclosingInstanceType).canBeSeenBy((scope))) {
252
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317212
253
				enclosingInstanceType = new ProblemReferenceBinding(
254
							enclosingInstanceReference.compoundName,
255
							enclosingInstanceReference,
256
							ProblemReasons.NotVisible);
257
				scope.problemReporter().invalidType(this.enclosingInstance, enclosingInstanceType);
258
				hasError = true;
250
			} else {
259
			} else {
251
				receiverType = ((SingleTypeReference) this.type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType);
260
				receiverType = ((SingleTypeReference) this.type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType);
252
				if (receiverType != null && enclosingInstanceContainsCast) {
261
				if (receiverType != null && enclosingInstanceContainsCast) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java (+79 lines)
Lines 35-40 Link Here
35
public static Test suite() {
35
public static Test suite() {
36
	return buildAllCompliancesTestSuite(testClass());
36
	return buildAllCompliancesTestSuite(testClass());
37
}
37
}
38
39
static {
40
//	TESTS_NAMES = new String [] { "test096" };
41
}
38
/**
42
/**
39
 * Non-static member class
43
 * Non-static member class
40
 */
44
 */
Lines 3097-3102 Link Here
3097
	"The type p1.B1 is not visible\n" + 
3101
	"The type p1.B1 is not visible\n" + 
3098
	"----------\n");
3102
	"----------\n");
3099
}
3103
}
3104
// https://bugs.eclipse.org/bugs/show_bug.cgi?id= 317212
3105
public void test096() {
3106
	this.runNegativeTest(
3107
		new String[] {
3108
			"p0/B.java",//------------------------------
3109
			"package p0;\n" +
3110
			"public class B {\n" +
3111
			"    public static A m() {\n" +
3112
			"        return new A();\n" +
3113
			"    }\n" +
3114
			"}\n" +
3115
			"class A {\n" +
3116
			"        public class M {\n" +
3117
			"            public M() {}\n" +
3118
			"        }\n" +
3119
			"}\n",
3120
			"p1/C.java",//------------------------------
3121
			"package p1;\n" +
3122
			"import p0.B;\n" +
3123
			"public class C {\n" +
3124
			"    public static void main(String[] args) {\n" +
3125
			"        B.m().new M();\n" +
3126
			"    }\n" +
3127
			"}",
3128
		},
3129
		"----------\n" + 
3130
		"1. ERROR in p1\\C.java (at line 5)\n" + 
3131
		"	B.m().new M();\n" + 
3132
		"	^^^^^\n" + 
3133
		"The type p0.A is not visible\n" + 
3134
		"----------\n");
3135
}
3136
// https://bugs.eclipse.org/bugs/show_bug.cgi?id= 317212
3137
public void test097() {
3138
	this.runNegativeTest(
3139
		new String[] {
3140
			"B.java",//------------------------------
3141
			"public class B {\n" +
3142
			"    public static A m() {\n" +
3143
			"        return new B().new A();\n" +
3144
			"    }\n" +
3145
			"    private class A {\n" +
3146
			"        public class M {\n" +
3147
			"            public M() {}\n" +
3148
			"        }\n" +
3149
			"    }\n" +
3150
			"}\n" +
3151
			"class C {\n" +
3152
			"    public static void main(String[] args) {\n" +
3153
			"        B.m().new M();\n" +
3154
			"    }\n" +
3155
			"}\n",
3156
		},
3157
		"----------\n" + 
3158
		"1. WARNING in B.java (at line 3)\n" + 
3159
		"	return new B().new A();\n" + 
3160
		"	       ^^^^^^^^^^^^^^^\n" + 
3161
		"Access to enclosing constructor B.A() is emulated by a synthetic accessor method\n" + 
3162
		"----------\n" + 
3163
		"2. WARNING in B.java (at line 6)\n" + 
3164
		"	public class M {\n" + 
3165
		"	             ^\n" + 
3166
		"The type B.A.M is never used locally\n" + 
3167
		"----------\n" + 
3168
		"3. WARNING in B.java (at line 7)\n" + 
3169
		"	public M() {}\n" + 
3170
		"	       ^^^\n" + 
3171
		"The constructor B.A.M() is never used locally\n" + 
3172
		"----------\n" + 
3173
		"4. ERROR in B.java (at line 13)\n" + 
3174
		"	B.m().new M();\n" + 
3175
		"	^^^^^\n" + 
3176
		"The type B$A is not visible\n" + 
3177
		"----------\n");
3178
}
3100
public static Class testClass() {	return LookupTest.class;
3179
public static Class testClass() {	return LookupTest.class;
3101
}
3180
}
3102
}
3181
}

Return to bug 317212