mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-01 10:48:09 +07:00
[java-intentions] IDEA-299075 Better quick-fixes when generic method call has mismatched type
GitOrigin-RevId: 6fa73efcfb43cd7da05f95ef66c2cd40a3dc1a14
This commit is contained in:
committed by
intellij-monorepo-bot
parent
46c6cb94ad
commit
8a9959167b
@@ -0,0 +1,8 @@
|
||||
// "Replace 'Double.class' with 'Integer.class'" "true-preview"
|
||||
class Demo {
|
||||
native static <T> T tryCast(Object obj, Class<T> clazz);
|
||||
|
||||
void test(Object obj) {
|
||||
Integer i = tryCast(obj, Integer.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace 'Integer.class' with 'String.class'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
native static <T> List<T> filterIsInstance(Collection<?> collection, Class<? extends T> aClass);
|
||||
|
||||
void test(List<?> list) {
|
||||
List<String> strings = filterIsInstance(list, String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace 'Integer.class' with 'String.class'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
native static <T> List<T> filterIsInstance(Collection<?> collection, Class<? extends T> aClass);
|
||||
|
||||
void test(List<?> list) {
|
||||
List<String> stringsSync = Collections.synchronizedList(filterIsInstance(list, String.class));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Cast to 'long'" "true-preview"
|
||||
import java.util.function.*;
|
||||
|
||||
class Demo {
|
||||
void test(Function<String, String> input) {
|
||||
Function<String, Long> result = input.andThen(s -> (long) s.length());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
List<String> stringList = Collections.nCopies(10, String.valueOf(20));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
List<Set<String>> nCopiesNested = Collections.nCopies(10, Set.of(String.valueOf(20)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Adapt using 'new File()'" "true-preview"
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
class Demo {
|
||||
void test(int value) {
|
||||
Set<File> file = Set.of(new File("/etc/passwd"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Cast to 'long'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
Optional<Long> opt = Optional.of(123L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test(int value) {
|
||||
Optional<String> optStr = Optional.of(String.valueOf(value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.stream.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
Stream<String> stream = Stream.generate(() -> String.valueOf(Math.random()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Adapt using 'Math.toIntExact()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test(List<?> list) {
|
||||
List<Integer> intList = Collections.singletonList(Math.toIntExact(123L));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Adapt using 'Math.toIntExact()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test(List<?> list) {
|
||||
List<Integer> intList2 = Collections.unmodifiableList(Collections.singletonList(Math.toIntExact(123L)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace 'Double.class' with 'Integer.class'" "true-preview"
|
||||
class Demo {
|
||||
native static <T> T tryCast(Object obj, Class<T> clazz);
|
||||
|
||||
void test(Object obj) {
|
||||
Integer i = <caret>tryCast(obj, Double.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace 'Integer.class' with 'String.class'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
native static <T> List<T> filterIsInstance(Collection<?> collection, Class<? extends T> aClass);
|
||||
|
||||
void test(List<?> list) {
|
||||
List<String> strings = <caret>filterIsInstance(list, Integer.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace 'Integer.class' with 'String.class'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
native static <T> List<T> filterIsInstance(Collection<?> collection, Class<? extends T> aClass);
|
||||
|
||||
void test(List<?> list) {
|
||||
List<String> stringsSync = <caret>Collections.synchronizedList(filterIsInstance(list, Integer.class));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Cast to 'long'" "true-preview"
|
||||
import java.util.function.*;
|
||||
|
||||
class Demo {
|
||||
void test(Function<String, String> input) {
|
||||
Function<String, Long> result = input.andThen(s -> <caret>s.length());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
List<String> stringList = Collections.<caret>nCopies(10, 20);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
List<Set<String>> nCopiesNested = Collections.<caret>nCopies(10, Set.of(20));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Adapt using 'new File()'" "true-preview"
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
class Demo {
|
||||
void test(int value) {
|
||||
Set<File> file = Set.of("/etc/<caret>passwd");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Cast to 'long'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
Optional<Long> opt = <caret>Optional.of(123);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test(int value) {
|
||||
Optional<String> optStr = <caret>Optional.of(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Wrap using 'String.valueOf()'" "true-preview"
|
||||
import java.util.stream.*;
|
||||
|
||||
class Demo {
|
||||
void test() {
|
||||
Stream<String> stream = Stream.generate(() -> <caret>Math.random());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Adapt using 'Math.toIntExact()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test(List<?> list) {
|
||||
List<Integer> intList = <caret>Collections.singletonList(123L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Adapt using 'Math.toIntExact()'" "true-preview"
|
||||
import java.util.*;
|
||||
|
||||
class Demo {
|
||||
void test(List<?> list) {
|
||||
List<Integer> intList2 = <caret>Collections.unmodifiableList(Collections.singletonList(123L));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user