question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong calculation of generic type returned from lambda

See original GitHub issue

Assuming 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:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
testforstephencommented, Nov 17, 2022

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.

1reaction
testforstephencommented, Nov 17, 2022

I can reproduce it with your latest sample. Looks like a “wildcard capture” problem for generic type inference. Need look deeper for more details.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found