[java-intention] Create method reference from usage: improve return type guess (IDEA-314907)

GitOrigin-RevId: 2e4e2eb156dcf6e0a739d9efd8b75b398d14ff2f
This commit is contained in:
Tagir Valeev
2023-03-20 11:41:53 +01:00
committed by intellij-monorepo-bot
parent 31990e349d
commit ffca32cd79
6 changed files with 124 additions and 35 deletions

View File

@@ -0,0 +1,16 @@
// "Create method 'getKey'" "true"
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class X {
void x() {
Map<Double, List<String>> map = Stream.of("x").collect(Collectors.groupingBy(this::getKey));
}
private Double getKey(String s) {
return null;
}
}

View File

@@ -0,0 +1,14 @@
// "Create method 'hello'" "true"
import java.util.function.BiFunction;
class X {
void x() {
BiFunction<String, Integer, Double> fn = (s, i) -> ((double)s.length())/i;
BiFunction<String, Integer, Character> fn2 = fn.andThen(X::hello);
}
private static Character hello(Double aDouble) {
return null;
}
}

View File

@@ -0,0 +1,12 @@
// "Create method 'getKey'" "true"
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class X {
void x() {
Map<Double, List<String>> map = Stream.of("x").collect(Collectors.groupingBy(this::<caret>getKey));
}
}

View File

@@ -0,0 +1,10 @@
// "Create method 'hello'" "true"
import java.util.function.BiFunction;
class X {
void x() {
BiFunction<String, Integer, Double> fn = (s, i) -> ((double)s.length())/i;
BiFunction<String, Integer, Character> fn2 = fn.andThen(X::<caret>hello);
}
}