IDEA-113585 Cast to Type quick fix creates code that doesn't help

This commit is contained in:
Tagir Valeev
2017-09-19 16:07:40 +07:00
parent 6bb3451995
commit dede7b30f7
8 changed files with 95 additions and 12 deletions

View File

@@ -0,0 +1,22 @@
// "Apply conversion '.toArray(new Test.User[0])'" "true"
import java.util.List;
class Test {
interface User {
}
interface Query {
List<?> getResultList();
}
public User[] getAllUsers(Query readQuery) {
List<?> result = readQuery.getResultList();
return (result != null) ? result.toArray(new User[0]) : new User[0];
}
public static void main(String[] args) {
}
}

View File

@@ -0,0 +1,10 @@
// "Apply conversion '.toArray(new java.lang.String[0])'" "false"
import java.util.*;
class Return {
String[] foo() {
List<Number> list = new ArrayList<>();
list.add(1);
return list<caret>;
}
}

View File

@@ -0,0 +1,22 @@
// "Apply conversion '.toArray(new Test.User[0])'" "true"
import java.util.List;
class Test {
interface User {
}
interface Query {
List<?> getResultList();
}
public User[] getAllUsers(Query readQuery) {
List<?> result = readQuery.getResultList();
return (result != null) ? result.toAr<caret>ray() : new User[0];
}
public static void main(String[] args) {
}
}