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

Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java (-2 / +8 lines)
Lines 856-865 Link Here
856
			if (unit.scope != null) {
856
			if (unit.scope != null) {
857
				// fault in fields & methods
857
				// fault in fields & methods
858
				unit.scope.faultInTypes();
858
				unit.scope.faultInTypes();
859
				if (unit.scope != null && verifyMethods) {
859
				if (verifyMethods) {
860
					// http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
860
					// http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
861
 					// verify inherited methods
861
					// verify inherited methods
862
					unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
862
					unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
863
					if (!unit.scope.compilerOptions().reportDeprecationInsideDeprecatedCode) {
864
						// If we short circuited some error reporting earlier due to being unable to say precisely
865
						// if we are in a deprecated method, report those errors/warnings (if any) now.
866
						// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206
867
						unit.scope.reportDeprecatedTypesInSignatures();
868
					}
863
				}
869
				}
864
				// type checking
870
				// type checking
865
				unit.resolve();
871
				unit.resolve();
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (-9 / +14 lines)
Lines 168-184 Link Here
168
			if(inheritedMethod.isSynchronized() && !currentMethod.isSynchronized()) {
168
			if(inheritedMethod.isSynchronized() && !currentMethod.isSynchronized()) {
169
				problemReporter(currentMethod).missingSynchronizedOnInheritedMethod(currentMethod, inheritedMethod);
169
				problemReporter(currentMethod).missingSynchronizedOnInheritedMethod(currentMethod, inheritedMethod);
170
			}
170
			}
171
			if (options.reportDeprecationWhenOverridingDeprecatedMethod && inheritedMethod.isViewedAsDeprecated()) {
171
			if (inheritedMethod.isViewedAsDeprecated()) {
172
				if (!currentMethod.isViewedAsDeprecated() || options.reportDeprecationInsideDeprecatedCode) {
172
				if (options.reportDeprecationWhenOverridingDeprecatedMethod) {
173
					// check against the other inherited methods to see if they hide this inheritedMethod
173
					if (!currentMethod.isViewedAsDeprecated() || options.reportDeprecationInsideDeprecatedCode) {
174
					ReferenceBinding declaringClass = inheritedMethod.declaringClass;
174
						// check against the other inherited methods to see if they hide this inheritedMethod
175
					if (declaringClass.isInterface())
175
						ReferenceBinding declaringClass = inheritedMethod.declaringClass;
176
						for (int j = length; --j >= 0;)
176
						if (declaringClass.isInterface())
177
							if (i != j && methods[j].declaringClass.implementsInterface(declaringClass, false))
177
							for (int j = length; --j >= 0;)
178
								continue nextMethod;
178
								if (i != j && methods[j].declaringClass.implementsInterface(declaringClass, false))
179
									continue nextMethod;  // Srikanth - check this.
179
180
180
					problemReporter(currentMethod).overridesDeprecatedMethod(currentMethod, inheritedMethod);
181
						problemReporter(currentMethod).overridesDeprecatedMethod(currentMethod, inheritedMethod);
182
					}
181
				}
183
				}
184
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206
185
			if (currentMethod.isImplementing() && !currentMethod.isViewedAsDeprecated())
186
				currentMethod.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
182
			}
187
			}
183
		}
188
		}
184
		checkForBridgeMethod(currentMethod, inheritedMethod, allInheritedMethods);
189
		checkForBridgeMethod(currentMethod, inheritedMethod, allInheritedMethods);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (+5 lines)
Lines 813-816 Link Here
813
	for (int i = 0, length = this.topLevelTypes.length; i < length; i++)
813
	for (int i = 0, length = this.topLevelTypes.length; i < length; i++)
814
		this.topLevelTypes[i].verifyMethods(verifier);
814
		this.topLevelTypes[i].verifyMethods(verifier);
815
}
815
}
816
817
public void reportDeprecatedTypesInSignatures() {
818
	for (int i = 0, length = this.topLevelTypes.length; i < length; i++)
819
		this.topLevelTypes[i].reportDeprecatedTypesInSignatures();
820
}
816
}
821
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (+60 lines)
Lines 1295-1300 Link Here
1295
	}
1295
	}
1296
	return null; // should never reach this point
1296
	return null; // should never reach this point
1297
}
1297
}
1298
private void reportDeprecatedUsagesFor(MethodBinding method) {
1299
	// Deferred deprecation reporting. Now that the method verification is over, we are able to discover if
1300
	// ``method'' overrides an abstract method. If it does and that method is deprecated, then ``method'' itself
1301
	// should be considered to be implicitly deprecated. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206
1302
	if ((method.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0)
1303
		return;
1304
1305
	AbstractMethodDeclaration methodDecl = method.sourceMethod();
1306
	if (methodDecl == null)
1307
		return; // method could not be resolved in previous iteration
1308
1309
	TypeReference[] exceptionTypes = methodDecl.thrownExceptions;
1310
	if (exceptionTypes != null) {
1311
		int size = exceptionTypes.length;
1312
		for (int i = 0; i < size; i++) {
1313
			TypeReference anException = exceptionTypes[i];
1314
			if (anException != null && anException.resolvedType != null) {
1315
				if(!anException.resolvedType.isValidBinding())
1316
					continue;
1317
				if (anException.isTypeUseDeprecated(anException.resolvedType, methodDecl.scope)) {
1318
					methodDecl.scope.problemReporter().deprecatedType(anException.resolvedType, anException);
1319
				}
1320
			}
1321
		}
1322
	}
1323
1324
	Argument[] arguments = methodDecl.arguments;
1325
	if (arguments != null) {
1326
		int size = arguments.length;
1327
1328
		for (int i = 0; i < size; i++) {
1329
			Argument anArgument = arguments[i];
1330
			if (anArgument != null && anArgument.type != null && anArgument.type.resolvedType != null) {
1331
				if (!anArgument.type.resolvedType.isValidBinding())
1332
					continue;
1333
				if (anArgument.isTypeUseDeprecated(anArgument.type.resolvedType, methodDecl.scope)) {
1334
					methodDecl.scope.problemReporter().deprecatedType(anArgument.type.resolvedType, anArgument);
1335
				}
1336
			}
1337
		}
1338
	}
1339
1340
	if (!method.isConstructor() && methodDecl instanceof MethodDeclaration) {
1341
		TypeReference returnType = ((MethodDeclaration) methodDecl).returnType;
1342
		if (returnType != null && returnType.resolvedType != null && returnType.resolvedType.isValidBinding()) {
1343
			if (returnType.isTypeUseDeprecated(returnType.resolvedType, methodDecl.scope)) {
1344
				methodDecl.scope.problemReporter().deprecatedType(returnType.resolvedType, returnType);
1345
			}
1346
		}
1347
	}
1348
}
1298
public MethodBinding resolveTypesFor(MethodBinding method) {
1349
public MethodBinding resolveTypesFor(MethodBinding method) {
1299
	if ((method.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0)
1350
	if ((method.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0)
1300
		return method;
1351
		return method;
Lines 1617-1620 Link Here
1617
	for (int i = this.memberTypes.length; --i >= 0;)
1668
	for (int i = this.memberTypes.length; --i >= 0;)
1618
		 ((SourceTypeBinding) this.memberTypes[i]).verifyMethods(verifier);
1669
		 ((SourceTypeBinding) this.memberTypes[i]).verifyMethods(verifier);
1619
}
1670
}
1671
void reportDeprecatedTypesInSignatures() {
1672
1673
	for (int i = 0, length = this.methods.length; i < length; i++)
1674
		this.reportDeprecatedUsagesFor(this.methods[i]);
1675
1676
	for (int i = this.memberTypes.length; --i >= 0;)
1677
		((SourceTypeBinding) this.memberTypes[i]).reportDeprecatedTypesInSignatures();
1678
1679
}
1620
}
1680
}
(-)compiler/org/eclipse/jdt/internal/compiler/Compiler.java (-9 / +18 lines)
Lines 726-738 Link Here
726
		long resolveStart = System.currentTimeMillis();
726
		long resolveStart = System.currentTimeMillis();
727
		this.stats.parseTime += resolveStart - parseStart;
727
		this.stats.parseTime += resolveStart - parseStart;
728
728
729
		// fault in fields & methods
729
		if (unit.scope != null) {
730
		if (unit.scope != null)
730
			unit.scope.faultInTypes(); // fault in fields & methods
731
			unit.scope.faultInTypes();
731
			unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier()); // verify inherited methods
732
732
			if (!unit.scope.compilerOptions().reportDeprecationInsideDeprecatedCode) {
733
		// verify inherited methods
733
			    // If we short circuited some error reporting earlier due to being unable to say precisely
734
		if (unit.scope != null)
734
			    // if we are in a deprecated method, report those errors if any now.
735
			unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
735
			    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206
736
				unit.scope.reportDeprecatedTypesInSignatures();
737
			}
738
		}
736
739
737
		// type checking
740
		// type checking
738
		unit.resolve();
741
		unit.resolve();
Lines 845-854 Link Here
845
			if (unit.scope != null) {
848
			if (unit.scope != null) {
846
				// fault in fields & methods
849
				// fault in fields & methods
847
				unit.scope.faultInTypes();
850
				unit.scope.faultInTypes();
848
				if (unit.scope != null && verifyMethods) {
851
				if (verifyMethods) {
849
					// http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
852
					// http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
850
 					// verify inherited methods
853
					// verify inherited methods
851
					unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
854
					unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
855
					if (!unit.scope.compilerOptions().reportDeprecationInsideDeprecatedCode) {
856
						// If we short circuited some error reporting earlier due to being unable to say precisely
857
						// if we are in a deprecated method, report those errors/warnings (if any) now.
858
						// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206
859
						unit.scope.reportDeprecatedTypesInSignatures();
860
					}
852
				}
861
				}
853
				// type checking
862
				// type checking
854
				unit.resolve();
863
				unit.resolve();
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-1 / +15 lines)
Lines 472-478 Link Here
472
		if (scope.isDefinedInSameUnit(refType)) return false;
472
		if (scope.isDefinedInSameUnit(refType)) return false;
473
473
474
		// if context is deprecated, may avoid reporting
474
		// if context is deprecated, may avoid reporting
475
		if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
475
		if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode) {
476
			if (scope.isInsideDeprecatedCode())
477
				return false;
478
			if (scope instanceof MethodScope) {
479
				MethodScope mScope = (MethodScope) scope;
480
				if (!mScope.isInsideInitializer()) {
481
					MethodBinding method = ((AbstractMethodDeclaration) mScope.referenceContext).binding;
482
					// If method is still unresolved, answer false as we cannot conclusively say (yet)
483
					// whether the method is really an implementation of a deprecated interface.
484
					if ((method.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0)
485
						return false;
486
				}
487
			}
488
		}
489
		
476
		return true;
490
		return true;
477
	}
491
	}
478
492

Return to bug 247206