mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix IDEA-177668 "Replace stream chain with loop" exception on unresolved collection type
This commit is contained in:
@@ -313,7 +313,11 @@ abstract class TerminalOperation extends Operation {
|
||||
Project project = aClass.getProject();
|
||||
PsiClass baseClass = JavaPsiFacade.getInstance(project).findClass(superClass, aClass.getResolveScope());
|
||||
if(baseClass == null) return type;
|
||||
PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, aClass, PsiSubstitutor.EMPTY);
|
||||
PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getMaybeSuperClassSubstitutor(baseClass, aClass, PsiSubstitutor.EMPTY, null);
|
||||
if(superClassSubstitutor == null) {
|
||||
// inconsistent class hierarchy: probably something is not resolved
|
||||
superClassSubstitutor = PsiSubstitutor.EMPTY;
|
||||
}
|
||||
for (PsiTypeParameter baseParameter : baseClass.getTypeParameters()) {
|
||||
PsiClass substitution = PsiUtil.resolveClassInClassTypeOnly(superClassSubstitutor.substitute(baseParameter));
|
||||
if(substitution instanceof PsiTypeParameter) {
|
||||
|
||||
+9
@@ -113,6 +113,15 @@ public class Main {
|
||||
return integers;
|
||||
}
|
||||
|
||||
// Unresolved reference
|
||||
void f(Collection<? extends Foo> c) {
|
||||
R treeSet = new TreeSet();
|
||||
for (Foo foo : c) {
|
||||
treeSet.add(foo);
|
||||
}
|
||||
Set<Foo> uniqueDescriptors = treeSet;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Main().testAveragingDouble("a", "bbb", null, "cc", "dd", "eedasfasdfs");
|
||||
new Main().testAveragingInt("a", "bbb", null, "cc", "dd", "eedasfasdfs");
|
||||
|
||||
+6
@@ -46,6 +46,12 @@ public class Main {
|
||||
return IntStream.of(4, 2, 1).boxed().collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
// Unresolved reference
|
||||
void f(Collection<? extends Foo> c) {
|
||||
Set<Foo> uniqueDescriptors = c.stream()
|
||||
.collect(Collectors.toCollection(() -> new TreeSet()));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Main().testAveragingDouble("a", "bbb", null, "cc", "dd", "eedasfasdfs");
|
||||
new Main().testAveragingInt("a", "bbb", null, "cc", "dd", "eedasfasdfs");
|
||||
|
||||
Reference in New Issue
Block a user