mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
lambda: use wildcard bound for inferred param
This commit is contained in:
@@ -123,7 +123,14 @@ public class LambdaUtil {
|
||||
if (methodSignature != null) {
|
||||
final PsiType[] types = methodSignature.getParameterTypes();
|
||||
if (parameterIndex < types.length) {
|
||||
return resolveResult.getSubstitutor().substitute(types[parameterIndex]);
|
||||
final PsiType psiType = resolveResult.getSubstitutor().substitute(types[parameterIndex]);
|
||||
if (psiType instanceof PsiWildcardType) {
|
||||
final PsiType bound = ((PsiWildcardType)psiType).getBound();
|
||||
if (bound != null) {
|
||||
return bound;
|
||||
}
|
||||
}
|
||||
return psiType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,18 @@ class CastInference {
|
||||
foo((I1<Integer>)() -> 42);
|
||||
I1<Integer> i1 = (I1<Integer>)() -> 42;
|
||||
}
|
||||
}
|
||||
|
||||
class WildcardBoundsUsage {
|
||||
interface I<X> {
|
||||
boolean foo(X x);
|
||||
}
|
||||
|
||||
public I<Character> bar(I<? super Character> predicate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
I<Character> i = bar(c -> c.compareTo('x') < 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user