typetools / typetools/checker-framework
Surprising `error: [mustcall:methodref.receiver] Incompatible receiver type`
Open
Nobody has claimed this yet.
False Positive (false warning or imprecision)
ResourceLeakChecker
wontfix
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
The analyser complains about this method:
private static <T> List<String> toStringList(Collection<T> list)
{
if (list == null)
return null;
return list.stream().map(Object::toString).collect(Collectors.toList());
}
with
[javac] /home/jlewandowski/dev/cassandra/c18190-ecj/src/java/org/apache/cassandra/db/virtual/LocalRepairTables.java:460: error: [mustcall:methodref.receiver] Incompatible receiver type
[javac] return list.stream().map(Object::toString).collect(Collectors.toList());
[javac] ^
[javac] found : @MustCall Object
[javac] required: T[ extends @MustCallUnknown Object super @MustCall Void]
[javac] Consequence: method in @MustCall Object
[javac] @MustCall String toString(@MustCall Object this)
[javac] is not a valid method reference for method in @MustCallUnknown Function<T[ extends @MustCallUnknown Object super @MustCall Void], @MustCall String>
[javac] @MustCall String apply(@MustCall Function<T[ extends @MustCallUnknown Object super @MustCall Void], @MustCall String> this, T[ extends @MustCallUnknown Object super @MustCall Void] p0)
I must admit I do not understand why it complains :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the toStringList method in LocalRepairTables.java at line 460 and reproduce the reported [mustcall:methodref.receiver] diagnostic using the shown Java code. Trace how the analyser types Object::toString and the generic Collection stream; done means explaining the diagnostic and determining whether the analyser or the method reference needs correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100