javac warns about overload on subclasses trying to override a method from superclass where the method cause a overload warning even when the warning is suppressed.
See attached test case,
There are two behaviors I found odd, to reproduce what I described,
build with javac -Xlint:all TestOverload.java,
1. There is still one warning to be suppressed, at line 30,
> TestOverload.java:30: warning: [overloads] bar(IntFoo) in Impl is potentially ambiguous with bar(Foo<Integer>) in IntBar
> public void bar(IntFoo foo) {
> ^
> 1 warning
The source(Interface IntBar) where the problem is introduced is having SuppressWarnings, have all subclasses to do SuppressWarnings seems a little too much, also the message is not
obvious on what is the ambiguous. I misunderstood it as saying it
doesn't know which function to override.
2. If I remove the two lines of @SuppressWarnings at line 15 and 20, I
expected both line will cause overloads warning, but I only get one.
After suppress that one, then compile gives me another one.
Expected behavior:
1. The attached code should compile cleanly.
2. In IntBar, SuppressWarnings should only be needed on the new method causing overload warning, that is void bar(IntFoo arg)
See attached test case,
There are two behaviors I found odd, to reproduce what I described,
build with javac -Xlint:all TestOverload.java,
1. There is still one warning to be suppressed, at line 30,
> TestOverload.java:30: warning: [overloads] bar(IntFoo) in Impl is potentially ambiguous with bar(Foo<Integer>) in IntBar
> public void bar(IntFoo foo) {
> ^
> 1 warning
The source(Interface IntBar) where the problem is introduced is having SuppressWarnings, have all subclasses to do SuppressWarnings seems a little too much, also the message is not
obvious on what is the ambiguous. I misunderstood it as saying it
doesn't know which function to override.
2. If I remove the two lines of @SuppressWarnings at line 15 and 20, I
expected both line will cause overloads warning, but I only get one.
After suppress that one, then compile gives me another one.
Expected behavior:
1. The attached code should compile cleanly.
2. In IntBar, SuppressWarnings should only be needed on the new method causing overload warning, that is void bar(IntFoo arg)
- duplicates
-
JDK-8024947 javac should issue the potentially ambiguous overload warning only where the problem appears
- Closed
-
JDK-8024947 javac should issue the potentially ambiguous overload warning only where the problem appears
- Closed