eclipse-jdt / eclipse-jdt/eclipse.jdt.ui
Missing return in lamdas confuses JDT
- Dominant language
- Java
- Stars
- 59
- Forks
- 127
- Avg merge
- 22h 47m
- Merged PRs (30d)
- 28
Description
This is similar to a problem described already here:
- https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/759
Assume the following code:
```
CompletableFuture.supplyAsync(()->{
});
```
This results in these quick fixes:

of course neither of those produce any useful results, the first results in
```
CompletableFuture.supplyAsync((Supplier)()->{
});
```
the second (now with the same error):
```
CompletableFuture.thenApplyAsync(()->{
});
```
if one instead performs the refactoring "Convert to anonymous class creation",

the problem becomes a bit more clear:
```
CompletableFuture.supplyAsync(new Supplier() {
@Override
public U get() {
}
});
```
even though `U` is not really a valid choice, so we replace `U` with `Object`:
```
CompletableFuture.supplyAsync(new Supplier<>() {
@Override
public Object get() {
}
});
```
Finally we got what we would like have seen in the first place, **adding the missing return statement!**

Now one can choose to "convert to lamda expression" refactoring to get to a working state again...
Contributor guide
Assessment
This issue has not been assessed yet.