mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 23:39:39 +07:00
IDEA-191856 "Replace Optional.isPresent() condition with functional style expression" creates bad code when used with Type Promotion
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Main {
|
||||
void test(Optional<String> foo) {
|
||||
double bar = foo.map(s -> s.length() * 1.2).orElse(0.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "false"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Main {
|
||||
void test(Optional<String> foo) {
|
||||
int defaultValue = 0;
|
||||
double bar = foo.isPresent<caret>() ? foo.get().length() * 1.2 : defaultValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Main {
|
||||
void test(Optional<String> foo) {
|
||||
double bar = foo.isPresent<caret>() ? foo.get().length() * 1.2 : 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user