[analysis] IDEA-240049 Don't report "foreach not applicable" if type being iterated is unresolved

This patch adds the support of intersection types as requested per the
code review

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: eb4f8e42599d402d030b604548d6fd221d9a0448
This commit is contained in:
Nikita Eshkeev
2020-06-03 13:26:45 +03:00
committed by intellij-monorepo-bot
parent 33710de3ae
commit 6565d1d76e
2 changed files with 16 additions and 1 deletions
@@ -71,4 +71,19 @@ class Main {
for (String arg: <error descr="foreach not applicable to type 'Main.Hello'">iterableExistingHello</error>) { }
for (String arg: iterableUnresolvedWorld) {}
}
interface A {}
interface B {}
void test(Object x) {
java.util.Optional.of((A & B)x).ifPresent(valueOfAandB -> {
for(Object foo : <error descr="foreach not applicable to type 'Main.A & Main.B'">valueOfAandB</error>) {
System.out.println(foo);
}
});
java.util.Optional.of((A & <error descr="Cannot resolve symbol 'World'">World</error>)x).ifPresent(valueOfAandUnresolvedWorld -> {
for(Object foo : <error descr="foreach not applicable to type 'Main.A & World'">valueOfAandUnresolvedWorld</error>) {
System.out.println(foo);
}
});
}
}