ctolkmit / checker-framework

Automatically exported from code.google.com/p/checker-framework
0 stars 0 forks source link

Duplicated warning #373

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the Null Checker on the class below
import java.util.AbstractMap;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

public class Test extends AbstractMap<String, String> {
    @Override
    public Set<Map.Entry<String, String>> entrySet() {
        return Collections.emptySet();
    }
}

What is the expected output? What do you see instead?
Expected: (ideally) no warning
Actual: The same warning is issued twice
    public Set<Map.Entry<String, String>> entrySet() {
              ^
  found   : Set<Entry<String, String>>
  required: Set<Entry<@KeyFor("this") String, String>>
...
    public Set<Map.Entry<String, String>> entrySet() {
              ^
  found   : Set<Entry<String, String>>
  required: Set<Entry<@KeyFor("this") String, String>>
2 warnings

What version of the product are you using? On what operating system?
1.8.6/Windows 8/Java 8

Original issue reported on code.google.com by ClovisSe...@gmail.com on 4 Oct 2014 at 11:03

GoogleCodeExporter commented 9 years ago
I can't reproduce this issue on Linux.
I get one single error:

Issue373.java:8: error: [override.return.invalid] Set<Entry<String, String>> 
entrySet(Issue373 this) in Issue373 cannot override Set<Entry<@KeyFor("this") 
String, String>> entrySet(Map<String, String> this) in java.util.Map; 
attempting to use an incompatible return type
    public Set<Map.Entry<String, String>> entrySet() {
              ^
  found   : Set<Entry<String, String>>
  required: Set<Entry<@KeyFor("this") String, String>>
1 error

Can you copy the full error message?
When you say Java 8, do you mean just as runtime or are you using the Java 8 
compiler instead of the Checker Framework compiler?

Original comment by wdi...@gmail.com on 14 Oct 2014 at 4:32

GoogleCodeExporter commented 9 years ago
C:\Test\src>java -jar c:\checker-framework-1.8.6\checker\dist\checker.jar 
-processor org.checkerframework.checker.nullness.NullnessChecker -Awarns 
Test.java
Test.java:8: warning: [override.return.invalid] Set<Entry<String, String>> 
entrySet(Test this) in Test cannot override Set<Entry<@KeyFor("th
is") String, String>> entrySet(AbstractMap<String, String> this) in 
java.util.AbstractMap; attempting to use an incompatible return type
    public Set<Map.Entry<String, String>> entrySet() {
              ^
  found   : Set<Entry<String, String>>
  required: Set<Entry<@KeyFor("this") String, String>>
Test.java:8: warning: [override.return.invalid] Set<Entry<String, String>> 
entrySet(Test this) in Test cannot override Set<Entry<@KeyFor("this") String, 
String>> entrySet(Map<String, String> this) in java.util.Map; attempting to use 
an incompatible return type
    public Set<Map.Entry<String, String>> entrySet() {
              ^
  found   : Set<Entry<String, String>>
  required: Set<Entry<@KeyFor("this") String, String>>
2 warnings

Original comment by ClovisSe...@gmail.com on 14 Oct 2014 at 9:28

GoogleCodeExporter commented 9 years ago
Thanks for showing the command line! It's the -Awarns. Without it, I get 1 
error; with it, I get 2 warnings.
I'll look into what's going wrong here. I don't get this behavior for other 
errors, e.g. I don't get this for an assignment.type.incompatible.

Original comment by wdi...@gmail.com on 15 Oct 2014 at 1:30

GoogleCodeExporter commented 9 years ago
Thanks again for the report! I pushed a fix:
https://code.google.com/p/checker-framework/source/detail?r=56fcf1daa220a0363e74
dc163da52899100977b1

Original comment by wdi...@gmail.com on 15 Oct 2014 at 2:33

GoogleCodeExporter commented 9 years ago
Fixed in release 1.8.7

Original comment by Jonathan...@gmail.com on 30 Oct 2014 at 11:12