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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-10 / +6 lines)
Lines 354-363 Link Here
354
354
355
	public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, boolean isStrictlyAssigned) {
355
	public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope, boolean isStrictlyAssigned) {
356
		// ignore references insing Javadoc comments
356
		// ignore references insing Javadoc comments
357
		if ((this.bits & ASTNode.InsideJavadoc) ==0 &&
357
		if ((this.bits & ASTNode.InsideJavadoc) == 0 && !isStrictlyAssigned && field.isOrEnclosedByPrivateType() && !scope.isDefinedInField(field)) {
358
				!isStrictlyAssigned &&
358
			// ignore cases where field is used from inside itself
359
				(field.isPrivate() || (field.declaringClass != null && field.declaringClass.isLocalType())) && !scope.isDefinedInField(field)) {
360
			// ignore cases where field is used from within inside itself
361
			field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
359
			field.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
362
		}
360
		}
363
361
Lines 392-400 Link Here
392
	public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
390
	public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
393
			boolean isExplicitUse) {
391
			boolean isExplicitUse) {
394
		// ignore references insing Javadoc comments
392
		// ignore references insing Javadoc comments
395
		if ((this.bits & ASTNode.InsideJavadoc) ==0 &&
393
		if ((this.bits & ASTNode.InsideJavadoc) == 0 && method.isOrEnclosedByPrivateType() && !scope.isDefinedInMethod(method)) {
396
				(method.isPrivate() || method.declaringClass.isLocalType()) && !scope.isDefinedInMethod(method)) {
394
			// ignore cases where method is used from inside itself (e.g. direct recursions)
397
			// ignore cases where method is used from within inside itself (e.g. direct recursions)
398
			method.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
395
			method.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
399
		}
396
		}
400
397
Lines 451-459 Link Here
451
448
452
		ReferenceBinding refType = (ReferenceBinding) type;
449
		ReferenceBinding refType = (ReferenceBinding) type;
453
		// ignore references insing Javadoc comments
450
		// ignore references insing Javadoc comments
454
		if ((this.bits & ASTNode.InsideJavadoc) == 0 &&
451
		if ((this.bits & ASTNode.InsideJavadoc) == 0 && refType.isOrEnclosedByPrivateType() && !scope.isDefinedInType(refType)) {
455
				(refType.isPrivate() || refType.isLocalType()) && !scope.isDefinedInType(refType)) {
452
			// ignore cases where type is used from inside itself
456
			// ignore cases where type is used from within inside itself
457
			((ReferenceBinding)refType.erasure()).modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
453
			((ReferenceBinding)refType.erasure()).modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
458
		}
454
		}
459
455
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java (-5 / +3 lines)
Lines 51-61 Link Here
51
}
51
}
52
52
53
public FlowInfo analyseCode(MethodScope initializationScope, FlowContext flowContext, FlowInfo flowInfo) {
53
public FlowInfo analyseCode(MethodScope initializationScope, FlowContext flowContext, FlowInfo flowInfo) {
54
	if (this.binding != null && !this.binding.isUsed()) {
54
	if (this.binding != null && !this.binding.isUsed() && this.binding.isOrEnclosedByPrivateType()) {
55
		if (this.binding.isPrivate() || (this.binding.declaringClass != null && this.binding.declaringClass.isLocalType())) {
55
		if (!initializationScope.referenceCompilationUnit().compilationResult.hasSyntaxError) {
56
			if (!initializationScope.referenceCompilationUnit().compilationResult.hasSyntaxError) {
56
			initializationScope.problemReporter().unusedPrivateField(this);
57
				initializationScope.problemReporter().unusedPrivateField(this);
58
			}
59
		}
57
		}
60
	}
58
	}
61
	// cannot define static non-constant field inside nested class
59
	// cannot define static non-constant field inside nested class
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java (-1 / +1 lines)
Lines 59-65 Link Here
59
		if (constructorBinding.isPrivate()) {
59
		if (constructorBinding.isPrivate()) {
60
			if ((this.binding.declaringClass.tagBits & TagBits.HasNonPrivateConstructor) == 0)
60
			if ((this.binding.declaringClass.tagBits & TagBits.HasNonPrivateConstructor) == 0)
61
				break checkUnused; // tolerate as known pattern to block instantiation
61
				break checkUnused; // tolerate as known pattern to block instantiation
62
		} else if ((this.binding.declaringClass.tagBits & (TagBits.IsAnonymousType|TagBits.IsLocalType)) != TagBits.IsLocalType) {
62
		} else if (!constructorBinding.isOrEnclosedByPrivateType()) {
63
			break checkUnused;
63
			break checkUnused;
64
		}
64
		}
65
		// complain unused
65
		// complain unused
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java (-1 / +1 lines)
Lines 611-617 Link Here
611
 *	Common flow analysis for all types
611
 *	Common flow analysis for all types
612
 */
612
 */
613
private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
613
private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
614
	if ((this.binding.isPrivate() || (this.binding.tagBits & (TagBits.IsAnonymousType|TagBits.IsLocalType)) == TagBits.IsLocalType) && !this.binding.isUsed()) {
614
	if (!this.binding.isUsed() && this.binding.isOrEnclosedByPrivateType()) {
615
		if (!this.scope.referenceCompilationUnit().compilationResult.hasSyntaxError) {
615
		if (!this.scope.referenceCompilationUnit().compilationResult.hasSyntaxError) {
616
			this.scope.problemReporter().unusedPrivateType(this);
616
			this.scope.problemReporter().unusedPrivateType(this);
617
		}
617
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java (-5 / +7 lines)
Lines 47-57 Link Here
47
			if (this.binding == null)
47
			if (this.binding == null)
48
				return;
48
				return;
49
49
50
			if (!this.binding.isUsed() &&
50
			if (!this.binding.isUsed()) {
51
					(this.binding.isPrivate()
51
				if (this.binding.isPrivate()
52
						|| (((this.binding.modifiers & (ExtraCompilerModifiers.AccOverriding|ExtraCompilerModifiers.AccImplementing)) == 0) && this.binding.declaringClass.isLocalType()))) {
52
					|| (((this.binding.modifiers & (ExtraCompilerModifiers.AccOverriding|ExtraCompilerModifiers.AccImplementing)) == 0)
53
				if (!classScope.referenceCompilationUnit().compilationResult.hasSyntaxError) {
53
						&& this.binding.isOrEnclosedByPrivateType())) {
54
					this.scope.problemReporter().unusedPrivateMethod(this);
54
					if (!classScope.referenceCompilationUnit().compilationResult.hasSyntaxError) {
55
						this.scope.problemReporter().unusedPrivateMethod(this);
56
					}
55
				}
57
				}
56
			}
58
			}
57
59
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (+14 lines)
Lines 1077-1082 Link Here
1077
}
1077
}
1078
1078
1079
/**
1079
/**
1080
 * Answer true if the receiver or any of its enclosing types have private visibility
1081
 */
1082
public final boolean isOrEnclosedByPrivateType() {
1083
	if (isLocalType()) return true; // catch all local types
1084
	ReferenceBinding type = this;
1085
	while (type != null) {
1086
		if ((type.modifiers & ClassFileConstants.AccPrivate) != 0)
1087
			return true;
1088
		type = type.enclosingType();
1089
	}
1090
	return false;
1091
}
1092
1093
/**
1080
 * Answer true if the receiver has protected visibility
1094
 * Answer true if the receiver has protected visibility
1081
 */
1095
 */
1082
public final boolean isProtected() {
1096
public final boolean isProtected() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java (+9 lines)
Lines 748-753 Link Here
748
public final boolean isPrivate() {
748
public final boolean isPrivate() {
749
	return (this.modifiers & ClassFileConstants.AccPrivate) != 0;
749
	return (this.modifiers & ClassFileConstants.AccPrivate) != 0;
750
}
750
}
751
752
/* Answer true if the receiver has private visibility or if any of its enclosing types do.
753
*/
754
public final boolean isOrEnclosedByPrivateType() {
755
	if ((this.modifiers & ClassFileConstants.AccPrivate) != 0)
756
		return true;
757
	return this.declaringClass != null && this.declaringClass.isOrEnclosedByPrivateType();
758
}
759
751
/* Answer true if the receiver has protected visibility
760
/* Answer true if the receiver has protected visibility
752
*/
761
*/
753
public final boolean isProtected() {
762
public final boolean isProtected() {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java (+8 lines)
Lines 286-291 Link Here
286
public final boolean isPrivate() {
286
public final boolean isPrivate() {
287
	return (this.modifiers & ClassFileConstants.AccPrivate) != 0;
287
	return (this.modifiers & ClassFileConstants.AccPrivate) != 0;
288
}
288
}
289
/* Answer true if the receiver has private visibility or is enclosed by a class that does.
290
*/
291
292
public final boolean isOrEnclosedByPrivateType() {
293
	if ((this.modifiers & ClassFileConstants.AccPrivate) != 0)
294
		return true;
295
	return this.declaringClass != null && this.declaringClass.isOrEnclosedByPrivateType();
296
}
289
/* Answer true if the receiver has private visibility and is used locally
297
/* Answer true if the receiver has private visibility and is used locally
290
*/
298
*/
291
299
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (+1 lines)
Lines 40-45 Link Here
40
40
41
	void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding supertype) {
41
	void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding supertype) {
42
		LocalTypeBinding anonymousType = buildLocalType(enclosingType, supertype, enclosingType.fPackage);
42
		LocalTypeBinding anonymousType = buildLocalType(enclosingType, supertype, enclosingType.fPackage);
43
		anonymousType.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; // tag all anonymous types as used locally
43
		if (supertype.isInterface()) {
44
		if (supertype.isInterface()) {
44
			anonymousType.superclass = getJavaLangObject();
45
			anonymousType.superclass = getJavaLangObject();
45
			anonymousType.superInterfaces = new ReferenceBinding[] { supertype };
46
			anonymousType.superInterfaces = new ReferenceBinding[] { supertype };
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (+7 lines)
Lines 205-210 Link Here
205
	if (concreteMethod.thrownExceptions != Binding.NO_EXCEPTIONS)
205
	if (concreteMethod.thrownExceptions != Binding.NO_EXCEPTIONS)
206
		for (int i = abstractMethods.length; --i >= 0;)
206
		for (int i = abstractMethods.length; --i >= 0;)
207
			checkExceptions(concreteMethod, abstractMethods[i]);
207
			checkExceptions(concreteMethod, abstractMethods[i]);
208
//	if (concreteMethod.isOrEnclosedByPrivateType()) { //WHY do this check at all ?
209
		// A subclass inheriting this method and putting it up as the implementation to meet its own
210
		// obligations should qualify as a use.
211
		concreteMethod.original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
212
		for (int i = abstractMethods.length; --i >= 0;)
213
			abstractMethods[i].original().modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
214
//	}
208
}
215
}
209
216
210
/*
217
/*
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java (+56 lines)
Lines 138-141 Link Here
138
		"Zork cannot be resolved to a type\n" +
138
		"Zork cannot be resolved to a type\n" +
139
		"----------\n");
139
		"----------\n");
140
}
140
}
141
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201912, test to make sure that unused public members of 
142
// private class (including constructors, fields, types and methods) get warned about.
143
public void test004() {
144
	this.runNegativeTest(
145
		new String[] {
146
				"X.java",
147
				"public class X {\n" +
148
				"	private class M { \n" + // expect unused field, method, constructor and type warnings
149
				"       private int state = 0;\n" +
150
				"       public int unusedMethod() { return this.state; }\n" +
151
				"       public M (int state) { this.state = state;} \n" +
152
				"       public int unusedField = 0;\n" +
153
				"       public class N {}\n" +
154
				"	}\n" +
155
				"	private class N { \n" +  // No warnings should come from within here
156
				"       private int state = 0;\n" +
157
				"       public int usedMethod() { new O(); return new N(this.state + this.usedField).state; }\n" +
158
				"       public N (int state) { this.state = state;} \n" +
159
				"       public int usedField = 0;\n" +
160
				"       public class O {}\n" +
161
				"	}\n" +
162
				"	public class P { \n" + // No warnings should come from within here.
163
				"       private int state = 0;\n" +
164
				"       public int unusedMethod() { return this.state; }\n" +
165
				"       public P (int state) { this.state = state;} \n" +
166
				"       public int unusedField = 0;\n" +
167
				"       public class N {}\n" +
168
				"	}\n" +
169
				"	public M foo(M m, N n) {\n" +
170
				"   n.usedMethod(); return m;\n" +
171
				"	}\n" +
172
				"} \n"
173
			},
174
			"----------\n" + 
175
			"1. WARNING in X.java (at line 4)\n" + 
176
			"	public int unusedMethod() { return this.state; }\n" + 
177
			"	           ^^^^^^^^^^^^^^\n" + 
178
			"The method unusedMethod() from the type X.M is never used locally\n" + 
179
			"----------\n" + 
180
			"2. WARNING in X.java (at line 5)\n" + 
181
			"	public M (int state) { this.state = state;} \n" + 
182
			"	       ^^^^^^^^^^^^^\n" + 
183
			"The constructor X.M(int) is never used locally\n" + 
184
			"----------\n" + 
185
			"3. WARNING in X.java (at line 6)\n" + 
186
			"	public int unusedField = 0;\n" + 
187
			"	           ^^^^^^^^^^^\n" + 
188
			"The field X.M.unusedField is never read locally\n" + 
189
			"----------\n" + 
190
			"4. WARNING in X.java (at line 7)\n" + 
191
			"	public class N {}\n" + 
192
			"	             ^\n" + 
193
			"The type X.M.N is never used locally\n" + 
194
			"----------\n"
195
			);
196
}
141
}
197
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest.java (+49 lines)
Lines 271-276 Link Here
271
				"	}\n" +
271
				"	}\n" +
272
				"}\n" };
272
				"}\n" };
273
	}
273
	}
274
	// The fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=201912 results in these additional
275
	// diagnostics to be generated. Just as we arrange for the ``referencedClasses'' to be compiled
276
	// automatically, we need to include these diagnostics automatically in the expected messages.
277
	static String expectedDiagnosticsFromReferencedClasses = 
278
		"----------\n" + 
279
		"1. WARNING in test\\AbstractVisibility.java (at line 5)\n" + 
280
		"	public int avf_public = avf_private;\n" + 
281
		"	           ^^^^^^^^^^\n" + 
282
		"The field AbstractVisibility.AvcPrivate.avf_public is never read locally\n" + 
283
		"----------\n" + 
284
		"2. WARNING in test\\AbstractVisibility.java (at line 10)\n" + 
285
		"	public int avm_public() {\n" + 
286
		"	           ^^^^^^^^^^^^\n" + 
287
		"The method avm_public() from the type AbstractVisibility.AvcPrivate is never used locally\n" + 
288
		"----------\n" + 
289
		"----------\n" + 
290
		"1. WARNING in test\\Visibility.java (at line 5)\n" + 
291
		"	public int vf_public = vf_private;\n" + 
292
		"	           ^^^^^^^^^\n" + 
293
		"The field Visibility.VcPrivate.vf_public is never read locally\n" + 
294
		"----------\n" + 
295
		"2. WARNING in test\\Visibility.java (at line 11)\n" + 
296
		"	public int vm_public() {\n" + 
297
		"	           ^^^^^^^^^^^\n" + 
298
		"The method vm_public() from the type Visibility.VcPrivate is never used locally\n" + 
299
		"----------\n" + 
300
		"----------\n" + 
301
		"1. WARNING in test\\copy\\VisibilityPackage.java (at line 5)\n" + 
302
		"	public int vf_public = vf_private;\n" + 
303
		"	           ^^^^^^^^^\n" + 
304
		"The field VisibilityPackage.VpPrivate.vf_public is never read locally\n" + 
305
		"----------\n" + 
306
		"2. WARNING in test\\copy\\VisibilityPackage.java (at line 10)\n" + 
307
		"	public int vm_public() {\n" + 
308
		"	           ^^^^^^^^^^^\n" + 
309
		"The method vm_public() from the type VisibilityPackage.VpPrivate is never used locally\n" + 
310
		"----------\n" + 
311
		"----------\n" + 
312
		"1. WARNING in test\\copy\\VisibilityPublic.java (at line 5)\n" + 
313
		"	public int vf_public = vf_private;\n" + 
314
		"	           ^^^^^^^^^\n" + 
315
		"The field VisibilityPublic.VpPrivate.vf_public is never read locally\n" + 
316
		"----------\n" + 
317
		"2. WARNING in test\\copy\\VisibilityPublic.java (at line 10)\n" + 
318
		"	public int vm_public() {\n" + 
319
		"	           ^^^^^^^^^^^\n" + 
320
		"The method vm_public() from the type VisibilityPublic.VpPrivate is never used locally\n" + 
321
		"----------\n";
274
	/* (non-Javadoc)
322
	/* (non-Javadoc)
275
	 * @see junit.framework.TestCase#setUp()
323
	 * @see junit.framework.TestCase#setUp()
276
	 */
324
	 */
Lines 312-317 Link Here
312
			completedFiles = new String[testFiles.length + referencedClasses.length];
360
			completedFiles = new String[testFiles.length + referencedClasses.length];
313
			System.arraycopy(referencedClasses, 0, completedFiles, 0, referencedClasses.length);
361
			System.arraycopy(referencedClasses, 0, completedFiles, 0, referencedClasses.length);
314
			System.arraycopy(testFiles, 0, completedFiles, referencedClasses.length, testFiles.length);
362
			System.arraycopy(testFiles, 0, completedFiles, referencedClasses.length, testFiles.length);
363
			expected = expectedDiagnosticsFromReferencedClasses + expected;
315
		}
364
		}
316
		runNegativeTest(completedFiles, expected, javacTestOptions);
365
		runNegativeTest(completedFiles, expected, javacTestOptions);
317
	}
366
	}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java (-8 / +33 lines)
Lines 1468-1474 Link Here
1468
		"	              ^\n" +
1468
		"	              ^\n" +
1469
		"Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" +
1469
		"Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" +
1470
		"----------\n" +
1470
		"----------\n" +
1471
		"3. ERROR in p1\\A2.java (at line 20)\n" +
1471
		"3. WARNING in p1\\A2.java (at line 19)\n" +
1472
		"	public void foo() {	\n" +
1473
		"	            ^^^^^\n" +
1474
		"The method foo() from the type A2.C is never used locally\n" +
1475
		"----------\n" +
1476
		"4. ERROR in p1\\A2.java (at line 20)\n" +
1472
		"	(new D.E(null, null, null, new F(get()) {}) {}).execute();	\n" +
1477
		"	(new D.E(null, null, null, new F(get()) {}) {}).execute();	\n" +
1473
		"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
1478
		"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
1474
		"No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" +
1479
		"No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" +
Lines 1556-1562 Link Here
1556
		"	              ^\n" +
1561
		"	              ^\n" +
1557
		"Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" +
1562
		"Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" +
1558
		"----------\n" +
1563
		"----------\n" +
1559
		"3. ERROR in p1\\A2.java (at line 20)\n" +
1564
		"3. WARNING in p1\\A2.java (at line 19)\n" +
1565
		"	public void foo() {	\n" +
1566
		"	            ^^^^^\n" +
1567
		"The method foo() from the type A2.C is never used locally\n" +
1568
		"----------\n" +
1569
		"4. ERROR in p1\\A2.java (at line 20)\n" +
1560
		"	(new D.E(null, null, null, new F(get()) {})).execute();	\n" +
1570
		"	(new D.E(null, null, null, new F(get()) {})).execute();	\n" +
1561
		"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
1571
		"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
1562
		"No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" +
1572
		"No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" +
Lines 5579-5585 Link Here
5579
			"}", // =================,
5589
			"}", // =================,
5580
		},
5590
		},
5581
		"----------\n" +
5591
		"----------\n" +
5582
		"1. ERROR in p\\X.java (at line 11)\n" +
5592
		"1. WARNING in p\\X.java (at line 5)\n" +
5593
		"	String variable = \"my testing\";\n" +
5594
		"	       ^^^^^^^^\n" +
5595
		"The field X.Outer.Inner.variable is never read locally\n" + 
5596
		"----------\n" +
5597
		"2. ERROR in p\\X.java (at line 11)\n" +
5583
		"	Zork z;\n" +
5598
		"	Zork z;\n" +
5584
		"	^^^^\n" +
5599
		"	^^^^\n" +
5585
		"Zork cannot be resolved to a type\n" +
5600
		"Zork cannot be resolved to a type\n" +
Lines 5633-5639 Link Here
5633
			"}", // =================,
5648
			"}", // =================,
5634
		},
5649
		},
5635
		"----------\n" +
5650
		"----------\n" +
5636
		"1. ERROR in p\\X.java (at line 12)\n" +
5651
		"1. WARNING in p\\X.java (at line 4)\n" + 
5652
		"	String variable = \"my testing\";\n" +
5653
		"	       ^^^^^^^^\n" + 
5654
		"The field X.Outer.Inner.variable is never read locally\n" + 
5655
		"----------\n" +
5656
		"2. ERROR in p\\X.java (at line 12)\n" +
5637
		"	Zork z;\n" +
5657
		"	Zork z;\n" +
5638
		"	^^^^\n" +
5658
		"	^^^^\n" +
5639
		"Zork cannot be resolved to a type\n" +
5659
		"Zork cannot be resolved to a type\n" +
Lines 6423-6444 Link Here
6423
				"	              ^^^^^\n" +
6443
				"	              ^^^^^\n" +
6424
				"The type X.Test4 is never used locally\n" +
6444
				"The type X.Test4 is never used locally\n" +
6425
				"----------\n" +
6445
				"----------\n" +
6426
				"2. ERROR in X.java (at line 16)\n" +
6446
				"2. WARNING in X.java (at line 13)\n" +
6447
				"	public Test4() {\n" +
6448
				"	       ^^^^^^^\n" +
6449
				"The constructor X.Test4() is never used locally\n" + 
6450
				"----------\n" +
6451
				"3. ERROR in X.java (at line 16)\n" +
6427
				"	System.out.println(X.this.var1.trim());\n" +
6452
				"	System.out.println(X.this.var1.trim());\n" +
6428
				"	                   ^^^^^^\n" +
6453
				"	                   ^^^^^^\n" +
6429
				"No enclosing instance of the type X is accessible in scope\n" +
6454
				"No enclosing instance of the type X is accessible in scope\n" +
6430
				"----------\n" +
6455
				"----------\n" +
6431
				"3. WARNING in X.java (at line 16)\n" +
6456
				"4. WARNING in X.java (at line 16)\n" +
6432
				"	System.out.println(X.this.var1.trim());\n" +
6457
				"	System.out.println(X.this.var1.trim());\n" +
6433
				"	                          ^^^^\n" +
6458
				"	                          ^^^^\n" +
6434
				"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
6459
				"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
6435
				"----------\n" +
6460
				"----------\n" +
6436
				"4. WARNING in X.java (at line 17)\n" +
6461
				"5. WARNING in X.java (at line 17)\n" +
6437
				"	System.out.println(var1.trim());\n" +
6462
				"	System.out.println(var1.trim());\n" +
6438
				"	                   ^^^^\n" +
6463
				"	                   ^^^^\n" +
6439
				"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
6464
				"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
6440
				"----------\n" +
6465
				"----------\n" +
6441
				"5. ERROR in X.java (at line 17)\n" +
6466
				"6. ERROR in X.java (at line 17)\n" +
6442
				"	System.out.println(var1.trim());\n" +
6467
				"	System.out.println(var1.trim());\n" +
6443
				"	                   ^^^^\n" +
6468
				"	                   ^^^^\n" +
6444
				"No enclosing instance of the type X is accessible in scope\n" +
6469
				"No enclosing instance of the type X is accessible in scope\n" +
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-1 / +6 lines)
Lines 41220-41226 Link Here
41220
		"The type A.P is not visible\n" +
41220
		"The type A.P is not visible\n" +
41221
		"----------\n" +
41221
		"----------\n" +
41222
		"----------\n" +
41222
		"----------\n" +
41223
		"1. WARNING in p\\A.java (at line 18)\n" +
41223
		"1. WARNING in p\\A.java (at line 9)\n" +
41224
		"	public int pval;\n" +
41225
		"	           ^^^^\n" +
41226
		"The field A.P.pval is never read locally\n" +
41227
		"----------\n" +
41228
		"2. WARNING in p\\A.java (at line 18)\n" +
41224
		"	this.box.set(new P());\n" +
41229
		"	this.box.set(new P());\n" +
41225
		"	             ^^^^^^^\n" +
41230
		"	             ^^^^^^^\n" +
41226
		"Access to enclosing constructor A.P() is emulated by a synthetic accessor method\n" +
41231
		"Access to enclosing constructor A.P() is emulated by a synthetic accessor method\n" +
(-)Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java (-7 / +34 lines)
Lines 7840-7851 Link Here
7840
		"	                     ^^^^^^\n" +
7840
		"	                     ^^^^^^\n" +
7841
		"The type AClass.Inner3 is never used locally\n" +
7841
		"The type AClass.Inner3 is never used locally\n" +
7842
		"----------\n" +
7842
		"----------\n" +
7843
		"2. WARNING in p\\z\\AClass.java (at line 18)\n" +
7843
		"2. WARNING in p\\z\\AClass.java (at line 14)\n" +
7844
		"	String test() {\n" +
7845
		"	       ^^^^^^\n" +
7846
		"The method test() from the type AClass.Inner3 is never used locally\n" +
7847
		"----------\n" +
7848
		"3. WARNING in p\\z\\AClass.java (at line 18)\n" +
7844
		"	private class Inner4 {\n" +
7849
		"	private class Inner4 {\n" +
7845
		"	              ^^^^^^\n" +
7850
		"	              ^^^^^^\n" +
7846
		"The type AClass.Inner4 is never used locally\n" +
7851
		"The type AClass.Inner4 is never used locally\n" +
7847
		"----------\n" +
7852
		"----------\n" +
7848
		"3. WARNING in p\\z\\AClass.java (at line 31)\n" +
7853
		"4. WARNING in p\\z\\AClass.java (at line 19)\n" +
7854
		"	String test() {\n" +
7855
		"	       ^^^^^^\n" +
7856
		"The method test() from the type AClass.Inner4 is never used locally\n" +
7857
		"----------\n" +
7858
		"5. WARNING in p\\z\\AClass.java (at line 31)\n" +
7849
		"	public String test() {\n" +
7859
		"	public String test() {\n" +
7850
		"	              ^^^^^^\n" +
7860
		"	              ^^^^^^\n" +
7851
		"The method test() from the type new Object(){} is never used locally\n" +
7861
		"The method test() from the type new Object(){} is never used locally\n" +
Lines 9035-9041 Link Here
9035
	"	int i = new AA().new Inner().i; // THIS LINE SHOULD CAUSE AN ERROR\n" +
9045
	"	int i = new AA().new Inner().i; // THIS LINE SHOULD CAUSE AN ERROR\n" +
9036
	"	                     ^^^^^\n" +
9046
	"	                     ^^^^^\n" +
9037
	"The type AA.Inner is not visible\n" +
9047
	"The type AA.Inner is not visible\n" +
9038
	"----------\n"	);
9048
	"----------\n" +
9049
	"----------\n" +
9050
	"1. WARNING in p\\k\\AA.java (at line 4)\n" +
9051
	"	int i = 10;\n" +
9052
	"	    ^\n" +
9053
	"The field AA.Inner.i is never read locally\n" +
9054
	"----------\n");
9039
}
9055
}
9040
public void test227() {
9056
public void test227() {
9041
	this.runNegativeTest(
9057
	this.runNegativeTest(
Lines 12204-12209 Link Here
12204
			"}	\n",
12220
			"}	\n",
12205
		},
12221
		},
12206
		"----------\n" +
12222
		"----------\n" +
12223
		"1. WARNING in p\\X.java (at line 4)\n" +
12224
		"	public class Z {	\n" +
12225
		"	             ^\n" +
12226
		"The type X.Y.Z is never used locally\n" +
12227
		"----------\n" +
12228
		"----------\n" +
12207
		"1. ERROR in q\\Y.java (at line 2)\n" +
12229
		"1. ERROR in q\\Y.java (at line 2)\n" +
12208
		"	import p.X.Y.Z;	\n" +
12230
		"	import p.X.Y.Z;	\n" +
12209
		"	       ^^^^^\n" +
12231
		"	       ^^^^^\n" +
Lines 16481-16502 Link Here
16481
		"	              ^^^^^^^\n" +
16503
		"	              ^^^^^^^\n" +
16482
		"Access to enclosing constructor X.M() is emulated by a synthetic accessor method\n" +
16504
		"Access to enclosing constructor X.M() is emulated by a synthetic accessor method\n" +
16483
		"----------\n" +
16505
		"----------\n" +
16484
		"4. WARNING in X.java (at line 9)\n" +
16506
		"4. WARNING in X.java (at line 6)\n" +
16507
		"	M.Member2 m2;\n" +
16508
		"	          ^^\n" +
16509
		"The field X.M.m2 is never read locally\n" +
16510
		"----------\n" +
16511
		"5. WARNING in X.java (at line 9)\n" +
16485
		"	class Local1 {} \n" +
16512
		"	class Local1 {} \n" +
16486
		"	      ^^^^^^\n" +
16513
		"	      ^^^^^^\n" +
16487
		"The type Local1 is never used locally\n" +
16514
		"The type Local1 is never used locally\n" +
16488
		"----------\n" +
16515
		"----------\n" +
16489
		"5. WARNING in X.java (at line 10)\n" +
16516
		"6. WARNING in X.java (at line 10)\n" +
16490
		"	class Local2 { \n" +
16517
		"	class Local2 { \n" +
16491
		"	      ^^^^^^\n" +
16518
		"	      ^^^^^^\n" +
16492
		"The type Local2 is never used locally\n" +
16519
		"The type Local2 is never used locally\n" +
16493
		"----------\n" +
16520
		"----------\n" +
16494
		"6. WARNING in X.java (at line 11)\n" +
16521
		"7. WARNING in X.java (at line 11)\n" +
16495
		"	class LMember1 {} \n" +
16522
		"	class LMember1 {} \n" +
16496
		"	      ^^^^^^^^\n" +
16523
		"	      ^^^^^^^^\n" +
16497
		"The type Local2.LMember1 is never used locally\n" +
16524
		"The type Local2.LMember1 is never used locally\n" +
16498
		"----------\n" +
16525
		"----------\n" +
16499
		"7. WARNING in X.java (at line 12)\n" +
16526
		"8. WARNING in X.java (at line 12)\n" +
16500
		"	class LMember2 extends Local2 { \n" +
16527
		"	class LMember2 extends Local2 { \n" +
16501
		"	      ^^^^^^^^\n" +
16528
		"	      ^^^^^^^^\n" +
16502
		"The type Local2.LMember2 is never used locally\n" +
16529
		"The type Local2.LMember2 is never used locally\n" +

Return to bug 201912