mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
unchecked warning: do not traverse through lambda bounds (IDEA-130810)
This commit is contained in:
+2
-1
@@ -375,8 +375,9 @@ public class UncheckedWarningLocalInspectionBase extends BaseJavaBatchLocalInspe
|
||||
public void visitReturnStatement(PsiReturnStatement statement) {
|
||||
super.visitReturnStatement(statement);
|
||||
if (IGNORE_UNCHECKED_ASSIGNMENT) return;
|
||||
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(statement, PsiLambdaExpression.class);
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(statement, PsiMethod.class);
|
||||
if (method != null) {
|
||||
if (method != null && (lambdaExpression == null || PsiTreeUtil.isAncestor(lambdaExpression, method, true))) {
|
||||
final PsiType returnType = method.getReturnType();
|
||||
if (returnType != null && returnType != PsiType.VOID) {
|
||||
final PsiExpression returnValue = statement.getReturnValue();
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Test {
|
||||
|
||||
private Repository repository = null;
|
||||
|
||||
public Stream<Person> test() {
|
||||
return repository.all()
|
||||
.flatMap(foo -> {
|
||||
|
||||
class AB {
|
||||
List<String> a() {
|
||||
return <warning descr="Unchecked assignment: 'java.util.ArrayList' to 'java.util.List<java.lang.String>'">new ArrayList()</warning>;
|
||||
}
|
||||
}
|
||||
|
||||
AB ab = new AB();
|
||||
System.out.println(ab);
|
||||
|
||||
if (foo != null) {
|
||||
return repository.update();
|
||||
}
|
||||
return Stream.empty();
|
||||
})
|
||||
.map(UpdateResult::getPerson);
|
||||
}
|
||||
|
||||
|
||||
public static class Repository {
|
||||
|
||||
public Stream<Person> all() {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
public Stream<UpdateResult> update() {
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Person {
|
||||
}
|
||||
|
||||
public static class UpdateResult {
|
||||
|
||||
private final Person person;
|
||||
|
||||
private final Object metadata;
|
||||
|
||||
public UpdateResult(Person person, Object metadata) {
|
||||
this.person = person;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public Person getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
public Object getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -762,6 +762,10 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
public void testIDEA78402() { doTest(); }
|
||||
|
||||
public void testUncheckedWarningInsideLambdaReturnStatement() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user