Bug 395051 - Access restriction on method invocation: error range too
big

Change-Id: I533f832054f79ee59b31e902bcfe466be62bf517
Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index ca13579..030401e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -2527,13 +2527,13 @@
        "----------\n" + 
        "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src2/Y.java (at line 4)\n" + 
        "	X<String> x2 = new X<String>();\n" + 
-       "	               ^^^^^^^^^^^^^^^\n" + 
-       "Discouraged access: The constructor \'X<String>()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + 
+       "	                   ^\n" + 
+       "Discouraged access: The type \'X<String>\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + 
        "----------\n" + 
        "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src2/Y.java (at line 4)\n" + 
        "	X<String> x2 = new X<String>();\n" + 
        "	                   ^\n" + 
-       "Discouraged access: The type \'X<String>\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + 
+       "Discouraged access: The constructor \'X<String>()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---/bin1\')\n" + 
        "----------\n" + 
        "5 problems (5 warnings)\n",
         false);
@@ -5331,17 +5331,17 @@
   "----------\n" + 
   "2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + 
   "	ko = new KO();\n" + 
-  "	     ^^^^^^^^\n" + 
-  "Access restriction: The constructor \'KO()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + 
+  "	         ^^\n" + 
+  "Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + 
   "----------\n" + 
   "3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 5)\n" + 
   "	ko = new KO();\n" + 
   "	         ^^\n" + 
-  "Access restriction: The type \'KO\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + 
+  "Access restriction: The constructor \'KO()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + 
   "----------\n" + 
   "4. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 6)\n" + 
   "	ko.bar();\n" + 
-  "	^^^^^^^^\n" + 
+  "	   ^^^\n" + 
   "Access restriction: The method \'KO.bar()\' is not API (restriction on classpath entry \'---OUTPUT_DIR_PLACEHOLDER---\')\n" + 
   "----------\n" + 
   "5. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 7)\n" + 
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java
index 59b37f6..994a526 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java
@@ -167,7 +167,7 @@
 			"----------\n" + 
 			"1. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
 			"	foo(); // accesses X1.foo, should trigger an error\n" + 
-			"	^^^^^\n" + 
+			"	^^^\n" + 
 			"Access restriction: The method \'X1.foo()\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n"
 		);
@@ -352,7 +352,7 @@
 			"----------\n" + 
 			"3. ERROR in /P2/src/p/Y.java (at line 6)\n" + 
 			"	foo();                // error\n" + 
-			"	^^^^^\n" + 
+			"	^^^\n" + 
 			"Access restriction: The method \'X1.C1.foo()\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n" + 
 			"4. ERROR in /P2/src/p/Y.java (at line 11)\n" + 
@@ -362,13 +362,13 @@
 			"----------\n" + 
 			"5. ERROR in /P2/src/p/Y.java (at line 12)\n" + 
 			"	new C1(0);      // error\n" + 
-			"	^^^^^^^^^\n" + 
-			"Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + 
+			"	    ^^\n" + 
+			"Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n" + 
 			"6. ERROR in /P2/src/p/Y.java (at line 12)\n" + 
 			"	new C1(0);      // error\n" + 
 			"	    ^^\n" + 
-			"Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + 
+			"Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n"
 		);
 	} finally {
@@ -531,7 +531,7 @@
 			"----------\n" + 
 			"1. ERROR in /P2/src/r/Y.java (at line 4)\n" + 
 			"	(new q.X2()).foo(); // accesses p.X1#foo, should trigger an error\n" + 
-			"	^^^^^^^^^^^^^^^^^^\n" + 
+			"	             ^^^\n" + 
 			"Access restriction: The method \'X1.foo()\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n"
 		);
@@ -617,13 +617,13 @@
 			"----------\n" + 
 			"3. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
 			"	X<String> x2 = new X<String>();\n" + 
-			"	               ^^^^^^^^^^^^^^^\n" + 
-			"Access restriction: The constructor \'X<String>()\' is not API (restriction on required project \'P1\')\n" + 
+			"	                   ^\n" + 
+			"Access restriction: The type \'X<String>\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n" + 
 			"4. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
 			"	X<String> x2 = new X<String>();\n" + 
 			"	                   ^\n" + 
-			"Access restriction: The type \'X<String>\' is not API (restriction on required project \'P1\')\n" + 
+			"Access restriction: The constructor \'X<String>()\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n");
 	} finally {
 		if (x != null) {
@@ -709,13 +709,13 @@
 			"----------\n" + 
 			"3. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
 			"	X<String> x2 = new X<String>(\"\");\n" + 
-			"	               ^^^^^^^^^^^^^^^^^\n" + 
-			"Access restriction: The constructor \'X<String>(String)\' is not API (restriction on required project \'P1\')\n" + 
+			"	                   ^\n" + 
+			"Access restriction: The type \'X<String>\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n" + 
 			"4. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
 			"	X<String> x2 = new X<String>(\"\");\n" + 
 			"	                   ^\n" + 
-			"Access restriction: The type \'X<String>\' is not API (restriction on required project \'P1\')\n" + 
+			"Access restriction: The constructor \'X<String>(String)\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n");
 	} finally {
 		if (x != null) {
@@ -800,7 +800,7 @@
 			"----------\n" + 
 			"1. ERROR in /P2/src/p/Y.java (at line 4)\n" + 
 			"	foo(); // accesses X1.foo, should trigger an error\n" + 
-			"	^^^^^\n" + 
+			"	^^^\n" + 
 			"Access restriction: The method \'X1.foo()\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n"
 		);
@@ -996,7 +996,7 @@
 			"----------\n" + 
 			"3. ERROR in /P2/src/p/Y.java (at line 6)\n" + 
 			"	foo();                // error\n" + 
-			"	^^^^^\n" + 
+			"	^^^\n" + 
 			"Access restriction: The method \'X1.C1.foo()\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n" + 
 			"4. ERROR in /P2/src/p/Y.java (at line 11)\n" + 
@@ -1006,13 +1006,13 @@
 			"----------\n" + 
 			"5. ERROR in /P2/src/p/Y.java (at line 12)\n" + 
 			"	new C1(0);      // error\n" + 
-			"	^^^^^^^^^\n" + 
-			"Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + 
+			"	    ^^\n" + 
+			"Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n" + 
 			"6. ERROR in /P2/src/p/Y.java (at line 12)\n" + 
 			"	new C1(0);      // error\n" + 
 			"	    ^^\n" + 
-			"Access restriction: The type \'X1.C1\' is not API (restriction on required project \'P1\')\n" + 
+			"Access restriction: The constructor \'X1.C1(int)\' is not API (restriction on required project \'P1\')\n" + 
 			"----------\n"
 		);
 	} finally {
@@ -1070,17 +1070,17 @@
 			"----------\n" + 
 			"2. ERROR in /P1/src/q/Y.java (at line 4)\n" + 
 			"	p.X x = new p.X();\n" + 
-			"	        ^^^^^^^^^\n" + 
-			"Access restriction: The constructor \'X()\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + 
+			"	            ^^^\n" + 
+			"Access restriction: The type \'X\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + 
 			"----------\n" + 
 			"3. ERROR in /P1/src/q/Y.java (at line 4)\n" + 
 			"	p.X x = new p.X();\n" + 
 			"	            ^^^\n" + 
-			"Access restriction: The type \'X\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + 
+			"Access restriction: The constructor \'X()\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + 
 			"----------\n" + 
 			"4. ERROR in /P1/src/q/Y.java (at line 5)\n" + 
 			"	x.foo();\n" + 
-			"	^^^^^^^\n" + 
+			"	  ^^^\n" + 
 			"Access restriction: The method \'X.foo()\' is not API (restriction on required library \'AccessRestrictions/lib.jar\')\n" + 
 			"----------\n" + 
 			"5. ERROR in /P1/src/q/Y.java (at line 6)\n" + 
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index 50391b4..78b31cc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -513,7 +513,7 @@
 	* An access in the same compilation unit is allowed.
 	*/
 	public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope,
-			boolean isExplicitUse) {
+			boolean isExplicitUse, InvocationSite invocation) {
 		// ignore references insing Javadoc comments
 		if ((this.bits & ASTNode.InsideJavadoc) == 0 && method.isOrEnclosedByPrivateType() && !scope.isDefinedInMethod(method)) {
 			// ignore cases where method is used from inside itself (e.g. direct recursions)
@@ -530,7 +530,7 @@
 			AccessRestriction restriction =
 				env.getAccessRestriction(method.declaringClass.erasure());
 			if (restriction != null) {
-				scope.problemReporter().forbiddenReference(method, this,
+				scope.problemReporter().forbiddenReference(method, invocation,
 						restriction.classpathEntryType, restriction.classpathEntryName,
 						restriction.getProblemId());
 			}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index 7710fcf..d53c24f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -503,7 +503,7 @@
 	if ((this.binding.tagBits & TagBits.HasMissingType) != 0) {
 		scope.problemReporter().missingTypeInConstructor(this, this.binding);
 	}
-	if (isMethodUseDeprecated(this.binding, scope, true)) {
+	if (isMethodUseDeprecated(this.binding, scope, true, this)) {
 		scope.problemReporter().deprecatedMethod(this.binding, this);
 	}
 	if (checkInvocationArguments(scope, null, this.resolvedType, this.binding, this.arguments, this.argumentTypes, this.argsContainCast, this)) {
@@ -809,4 +809,12 @@
 public InferenceContext18 freshInferenceContext(Scope scope) {
 	return new InferenceContext18(scope, this.arguments, this, this.outerInferenceContext);
 }
+@Override
+public int nameSourceStart() {
+	return this.type.sourceStart;
+}
+@Override
+public int nameSourceEnd() {
+	return this.type.sourceEnd;
+}
 }
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
index 0553640..de4fc80 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -446,7 +446,7 @@
 						scope.problemReporter().missingTypeInConstructor(this, this.binding);
 					}
 				}
-				if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper)) {
+				if (isMethodUseDeprecated(this.binding, scope, this.accessMode != ExplicitConstructorCall.ImplicitSuper, this)) {
 					scope.problemReporter().deprecatedMethod(this.binding, this);
 				}
 				if (checkInvocationArguments(scope, null, receiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java
index 7b69cf5..d0c1c6d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -144,7 +144,7 @@
 				}
 			}
 		}
-		if (isMethodUseDeprecated(this.binding, scope, true)) {
+		if (isMethodUseDeprecated(this.binding, scope, true, this)) {
 			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
 		}
 		return allocationType;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java
index a1988de..4fdc64d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -172,7 +172,7 @@
 				}
 			}
 		}
-		if (isMethodUseDeprecated(this.binding, scope, true)) {
+		if (isMethodUseDeprecated(this.binding, scope, true, this)) {
 			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
 		}
 
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
index 2421cfb..2e52f5a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -898,7 +898,7 @@
 		}
 		// abstract private methods cannot occur nor abstract static............
 	}
-	if (isMethodUseDeprecated(this.binding, scope, true))
+	if (isMethodUseDeprecated(this.binding, scope, true, this))
 		scope.problemReporter().deprecatedMethod(this.binding, this);
 
 	TypeBinding returnType;
@@ -1171,4 +1171,12 @@
 public boolean isQualifiedSuper() {
 	return this.receiver.isQualifiedSuper();
 }
+@Override
+public int nameSourceStart() {
+	return (int) (this.nameSourcePosition >>> 32);
+}
+@Override
+public int nameSourceEnd() {
+	return (int) this.nameSourcePosition;
+}
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index bed5d38..bd4ba12 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -561,7 +561,7 @@
 		ReferenceBinding receiver = (ReferenceBinding) receiverType;
 		ReferenceBinding superType = receiver.isInterface() ? scope.getJavaLangObject() : receiver;
 		if (constructorBinding.isValidBinding()) {
-			if (isMethodUseDeprecated(constructorBinding, scope, true)) {
+			if (isMethodUseDeprecated(constructorBinding, scope, true, this)) {
 				scope.problemReporter().deprecatedMethod(constructorBinding, this);
 			}
 			if (checkInvocationArguments(scope, null, superType, constructorBinding, this.arguments,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
index c7e4eb8..d6d044c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -799,7 +799,7 @@
         		srcMethod.bits &= ~ASTNode.CanBeStatic;
         }
         
-    	if (isMethodUseDeprecated(this.binding, scope, true))
+    	if (isMethodUseDeprecated(this.binding, scope, true, this))
     		scope.problemReporter().deprecatedMethod(this.binding, this);
 
     	if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
index 8513fed..aa57e12 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -34,6 +34,8 @@
 	void setFieldIndex(int depth);
 	int sourceEnd();
 	int sourceStart();
+	default int nameSourceStart() { return sourceStart(); }
+	default int nameSourceEnd() { return sourceEnd(); }
 	TypeBinding invocationTargetType();
 	boolean receiverIsImplicitThis();
 	boolean checkingPotentialCompatibility();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index a4db767..1a47e1d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -2453,7 +2453,7 @@
 }
 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
-public void forbiddenReference(MethodBinding method, ASTNode location,
+public void forbiddenReference(MethodBinding method, InvocationSite location,
 		byte classpathEntryType, String classpathEntryName, int problemId) {
 	int severity = computeSeverity(problemId);
 	if (severity == ProblemSeverities.Ignore) return;
@@ -2466,8 +2466,8 @@
 				classpathEntryName,
 				new String(method.shortReadableName())},
 			severity,
-			location.sourceStart,
-			location.sourceEnd);
+			location.nameSourceStart(),
+			location.nameSourceEnd());
 	else
 		this.handle(
 			problemId,
@@ -2478,8 +2478,8 @@
 				new String(method.shortReadableName()),
 		        new String(method.declaringClass.shortReadableName())},
 		    severity,
-			location.sourceStart,
-			location.sourceEnd);
+		    location.nameSourceStart(),
+			location.nameSourceEnd());
 }
 /** @param classpathEntryType one of {@link AccessRestriction#COMMAND_LINE},
  * {@link AccessRestriction#LIBRARY}, {@link AccessRestriction#PROJECT} */
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
index 2de2f1a..1536b4f 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -279,7 +279,7 @@
 			return this.resolvedType;
 		}
 	}
-	if (isMethodUseDeprecated(this.binding, scope, true)) {
+	if (isMethodUseDeprecated(this.binding, scope, true, this)) {
 		scope.problemReporter().deprecatedMethod(this.binding, this);
 	}
 	if (this.arguments != null) {
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java
index 98d1f86..9a00586 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -337,7 +337,7 @@
 		}
 		// abstract private methods cannot occur nor abstract static............
 	}
-	if (isMethodUseDeprecated(this.binding, scope, true))
+	if (isMethodUseDeprecated(this.binding, scope, true, this))
 		scope.problemReporter().deprecatedMethod(this.binding, this);
 
 	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)