Skip to content

Commit 3d38e39

Browse files
committed
Do not emit restriction warning on inherited method
Currently when we have a type A and it is accessible from package p1, but extends a type B (that is not accessible in package p2) calling any inherited public method A.M triggers a restriction warning. This is undesired because as a caller I never access any restricted code here as A is inherit all public methods from B. Adjust test001 to the changed behavior Adjust test003 to changed behavior Adjust test005 to changed behavior Adjust test008 to changed behavior Adjust test010 to changed behavior Adjust testBug528467b
1 parent 0dbe296 commit 3d38e39

File tree

3 files changed

+173
-143
lines changed

3 files changed

+173
-143
lines changed

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MessageSend.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272
import java.util.HashMap;
7373
import java.util.Map;
74+
import java.util.Objects;
7475
import java.util.function.BiConsumer;
7576
import org.eclipse.jdt.core.compiler.CharOperation;
7677
import org.eclipse.jdt.internal.compiler.ASTVisitor;
@@ -1002,7 +1003,10 @@ public TypeBinding resolveType(BlockScope scope) {
10021003
}
10031004
// abstract private methods cannot occur nor abstract static............
10041005
}
1005-
if (isMethodUseDeprecated(this.binding, scope, true, this))
1006+
TypeBinding declared = this.binding.declaringClass.erasure();
1007+
TypeBinding actual = this.actualReceiverType.erasure();
1008+
boolean isExplicitUse = Objects.equals( declared, actual);
1009+
if (isMethodUseDeprecated(this.binding, scope, isExplicitUse, this))
10061010
scope.problemReporter().deprecatedMethod(this.binding, this);
10071011

10081012
TypeBinding returnType;

0 commit comments

Comments
 (0)