mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-208770 Inspection OptionalGetWithoutIsPresent doesn't recognize check in stream
This commit is contained in:
+2
@@ -754,8 +754,10 @@ public class StreamChainInliner implements CallInliner {
|
||||
// exactly single element
|
||||
PsiExpression arg = sourceCall.getArgumentList().getExpressions()[0];
|
||||
builder
|
||||
.pushForWrite(builder.createTempVariable(inType))
|
||||
.pushExpression(arg)
|
||||
.boxUnbox(arg, inType)
|
||||
.assign()
|
||||
.chain(firstStep::before)
|
||||
.chain(firstStep::iteration);
|
||||
return;
|
||||
|
||||
@@ -429,4 +429,19 @@ class FinallyTest
|
||||
System.out.println(a.getAsInt());
|
||||
}
|
||||
}
|
||||
|
||||
class X {
|
||||
private String value;
|
||||
public Optional<String> getValue() {
|
||||
return Optional.ofNullable(value);
|
||||
}
|
||||
}
|
||||
|
||||
void testStream() {
|
||||
// IDEA-208770
|
||||
Stream.of(new X(), new X()).filter(x -> x.getValue().isPresent()).map(x -> x.getValue().get());
|
||||
Stream.of(new X()).filter(x -> x.getValue().isPresent()).map(x -> x.getValue().get());
|
||||
X xx = new X();
|
||||
Stream.of(xx).filter(x -> x.getValue().isPresent()).map(x -> x.getValue().get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user