Wrong calculation of generic type returned from lambda
See original GitHub issueAssuming we have
public void createTextEdit(Range range, String edit){
return For(Option(range), Option(edit))
.yield(TextEdit::new);
}
jdt would suggest change method return type to Option<Object>
while expected Option<TextEdit>
.
Same with .yield((r,d) -> new TextEdit(r,d))
P.S. Option and For…yield from https://www.vavr.io/ , Range and TextEdit from eclipse lsp4j
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Lambda return type as generic - java 8 - Stack Overflow
Lamda will identify the value of R based of value you are returning from your lamda. Note: If you are calling it a...
Read more >Excel LAMBDA function: how to write and use - Ablebits
Calculation (required) - the formula to execute or calculation to perform. It must be the last argument and it must return a result....
Read more >Lambda Expressions (The Java™ Tutorials > Learning the ...
Lambda expressions let you express instances of single-method classes more compactly. ... The following method is more generic than printPersonsOlderThan ...
Read more >Lambda Expressions - Visual Basic | Microsoft Learn
The following example defines a lambda expression that returns True if the nullable value type argument has an assigned value, and False if...
Read more >lambdas as parameters and return values - Kotlin in Action
In order to declare a function that takes a lambda as an argument, ... The Unit return type can be omitted when you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is a type inference problem introduced by the upstream ECJ (Eclipse Compiler for Java). We also found some generic type use cases where ECJ inferred a different expected type than javac. We’re trying to fix these inconsistencies in the upstream ECJ.
I can reproduce it with your latest sample. Looks like a “wildcard capture” problem for generic type inference. Need look deeper for more details.