mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
raw substitutor when erasure happened during inference
This commit is contained in:
+5
-2
@@ -366,7 +366,10 @@ public class InferenceSession {
|
||||
final InferenceVariable inferenceVariable = shouldResolveAndInstantiate(returnType, targetType);
|
||||
if (inferenceVariable != null) {
|
||||
final PsiSubstitutor substitutor = resolveSubset(Collections.singletonList(inferenceVariable), mySiteSubstitutor);
|
||||
myConstraints.add(new TypeCompatibilityConstraint(targetType, PsiUtil.captureToplevelWildcards(substitutor.substitute(inferenceVariable.getParameter()), myContext)));
|
||||
final PsiType substitutedReturnType = substitutor.substitute(inferenceVariable.getParameter());
|
||||
if (substitutedReturnType != null) {
|
||||
myConstraints.add(new TypeCompatibilityConstraint(targetType, PsiUtil.captureToplevelWildcards(substitutedReturnType, myContext)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(returnType)) {
|
||||
@@ -707,7 +710,7 @@ public class InferenceSession {
|
||||
substitutor = substitutor.put(typeParameter, runtimeException);
|
||||
}
|
||||
else {
|
||||
substitutor = substitutor.put(typeParameter, getUpperBound(var, substitutor));
|
||||
substitutor = substitutor.put(typeParameter, myErased ? null : getUpperBound(var, substitutor));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.Collection;
|
||||
|
||||
abstract class NCollections {
|
||||
public <T> void foo(Collection<? extends T> coll) {
|
||||
bar((Collection)coll);
|
||||
}
|
||||
|
||||
public abstract <T2 extends Object & Comparable<? super T2>> T2 bar(Collection<? extends T2> coll);
|
||||
}
|
||||
+3
-1
@@ -752,7 +752,9 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testSuperWildcardWithBoundPromotion() { doTest();}
|
||||
|
||||
|
||||
public void testErasure() throws Exception { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user