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:
Anna.Kozlova
2017-08-18 19:01:30 +02:00
parent 4875358e89
commit 07fa74c8b5
8 changed files with 95 additions and 24 deletions
@@ -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()));
}
}