mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Don't offer the quick-fix Collection.toArray() for type parameter arrays (like T[]) (IDEA-163341)
This commit is contained in:
+1
@@ -651,6 +651,7 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
if (toType instanceof PsiArrayType) {
|
||||
PsiType arrayComponentType = ((PsiArrayType)toType).getComponentType();
|
||||
if (!(arrayComponentType instanceof PsiPrimitiveType) &&
|
||||
!(PsiUtil.resolveClassInType(arrayComponentType) instanceof PsiTypeParameter) &&
|
||||
InheritanceUtil.isInheritor(fromType, CommonClassNames.JAVA_UTIL_COLLECTION)) {
|
||||
PsiType collectionItemType = JavaGenericsUtil.getCollectionItemType(fromType, expression.getResolveScope());
|
||||
if (collectionItemType != null && arrayComponentType.isAssignableFrom(collectionItemType)) {
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Apply conversion '.toArray(new T[0])'" "false"
|
||||
|
||||
import java.util.*;
|
||||
class TypeVar<T> {
|
||||
T[] foo() {
|
||||
Set<T> set = new HashSet<>();
|
||||
T[] arr = <caret>set;
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Apply conversion '.toArray(new T[0][])'" "false"
|
||||
|
||||
import java.util.*;
|
||||
class TypeVarArray<T> {
|
||||
T[][] foo() {
|
||||
Set<T[]> set = new HashSet<>();
|
||||
T[][] arr = <caret>set;
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user