mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-07-03 07:36:57 +07:00
inference: restore captured wildcard from fresh type parameter (IDEA-165871; IDEA-176592)
register return type constrain replaces wildcard parametrization with fresh variables aka custom capture conversion. When the specification would deal with these fresh type parameters further, IDEA expects them like PsiCapturedWildcards. Let's restore captured wildcards when inference failed to add any new constraints for fresh variables but initial upper bound of captured wildcard
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
abstract class MapToGeneric {
|
||||
void sdf(Stream<MapToGeneric> stream) {
|
||||
stream.map(mapToGeneric -> mapToGeneric.map("123"));
|
||||
}
|
||||
|
||||
abstract <T> Map<?, T> map(T t);
|
||||
}
|
||||
|
||||
|
||||
abstract class MapToGenericSimplified {
|
||||
{
|
||||
bar(() -> map()) ;
|
||||
bar(this::map) ;
|
||||
}
|
||||
|
||||
abstract <T> Map<T, ?> map();
|
||||
|
||||
abstract <R> R bar(Supplier<R> mapper);
|
||||
}
|
||||
|
||||
class Test {
|
||||
static class MyList<T, X> extends ArrayList<X> {}
|
||||
|
||||
static <T> MyList<? extends Number, T> create() {
|
||||
return new MyList<>();
|
||||
}
|
||||
|
||||
MyList<? extends Number, ? extends Number> test(List<? extends Number> list) {
|
||||
|
||||
return list.stream().collect(Collectors.toCollection(Test::create));
|
||||
}
|
||||
|
||||
MyList<? extends Number, ? extends Number> testLambda(List<? extends Number> list) {
|
||||
|
||||
return list.stream().collect(Collectors.toCollection(() -> create()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user