mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: cleanup incorporation phase
This commit is contained in:
+10
-32
@@ -89,28 +89,6 @@ public class InferenceIncorporationPhase {
|
||||
upDown(lowerBounds, eqBounds, substitutor);
|
||||
|
||||
upUp(upperBounds);
|
||||
|
||||
for (PsiType eqBound : eqBounds) {
|
||||
if (mySession.isProperType(eqBound)) {
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
if (!mySession.isProperType(upperBound)) {
|
||||
addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), eqBound));
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiType lowerBound : lowerBounds) {
|
||||
if (!mySession.isProperType(lowerBound)) {
|
||||
addConstraint(new StrictSubtypingConstraint(eqBound, substitutor.substitute(lowerBound)));
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiType otherEqBound : eqBounds) {
|
||||
if (eqBound != otherEqBound && !mySession.isProperType(otherEqBound)) {
|
||||
addConstraint(new TypeEqualityConstraint(substitutor.substitute(otherEqBound), eqBound));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Pair<PsiTypeParameter[], PsiClassType> capture : myCaptures) {
|
||||
@@ -135,7 +113,7 @@ public class InferenceIncorporationPhase {
|
||||
if (aType instanceof PsiWildcardType) {
|
||||
|
||||
for (PsiType eqBound : eqBounds) {
|
||||
if (mySession.isProperType(eqBound)) return false;
|
||||
if (mySession.getInferenceVariable(eqBound) == null) return false;
|
||||
}
|
||||
|
||||
final PsiClassType[] paramBounds = parameters[i].getExtendsListTypes();
|
||||
@@ -143,15 +121,15 @@ public class InferenceIncorporationPhase {
|
||||
if (!((PsiWildcardType)aType).isBounded()) {
|
||||
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
if (mySession.isProperType(upperBound)) {
|
||||
if (mySession.getInferenceVariable(upperBound) == null) {
|
||||
for (PsiClassType paramBound : paramBounds) {
|
||||
addConstraint(new StrictSubtypingConstraint(upperBound, paramBound));
|
||||
addConstraint(new StrictSubtypingConstraint(upperBound, mySession.substituteWithInferenceVariables(paramBound)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiType lowerBound : lowerBounds) {
|
||||
if (mySession.isProperType(lowerBound)) return false;
|
||||
if (mySession.getInferenceVariable(lowerBound) == null) return false;
|
||||
}
|
||||
|
||||
} else if (((PsiWildcardType)aType).isExtends()) {
|
||||
@@ -159,19 +137,19 @@ public class InferenceIncorporationPhase {
|
||||
final PsiType extendsBound = ((PsiWildcardType)aType).getExtendsBound();
|
||||
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
if (mySession.isProperType(upperBound)) {
|
||||
if (mySession.getInferenceVariable(upperBound) == null) {
|
||||
if (paramBounds.length == 1 && paramBounds[0].equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || paramBounds.length == 0) {
|
||||
addConstraint(new StrictSubtypingConstraint(upperBound, extendsBound));
|
||||
} else if (extendsBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
|
||||
for (PsiClassType paramBound : paramBounds) {
|
||||
addConstraint(new StrictSubtypingConstraint(upperBound, paramBound));
|
||||
addConstraint(new StrictSubtypingConstraint(upperBound, mySession.substituteWithInferenceVariables(paramBound)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiType lowerBound : lowerBounds) {
|
||||
if (mySession.isProperType(lowerBound)) return false;
|
||||
if (mySession.getInferenceVariable(lowerBound) == null) return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -179,15 +157,15 @@ public class InferenceIncorporationPhase {
|
||||
final PsiType superBound = ((PsiWildcardType)aType).getSuperBound();
|
||||
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
if (mySession.isProperType(upperBound)) {
|
||||
if (mySession.getInferenceVariable(upperBound) == null) {
|
||||
for (PsiClassType paramBound : paramBounds) {
|
||||
addConstraint(new StrictSubtypingConstraint(paramBound, upperBound));
|
||||
addConstraint(new StrictSubtypingConstraint(mySession.substituteWithInferenceVariables(paramBound), upperBound));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiType lowerBound : lowerBounds) {
|
||||
if (mySession.isProperType(lowerBound)) {
|
||||
if (mySession.getInferenceVariable(lowerBound) == null) {
|
||||
addConstraint(new StrictSubtypingConstraint(lowerBound, superBound));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -875,7 +875,7 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
//resolve input variables
|
||||
PsiSubstitutor substitutor = resolveSubset(varsToResolve, retrieveNonPrimitiveEqualsBounds(getInferenceVariables()).putAll(siteSubstitutor));
|
||||
PsiSubstitutor substitutor = resolveSubset(varsToResolve, siteSubstitutor);
|
||||
if (substitutor == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
class IdeaTest {
|
||||
class Test<K>{}
|
||||
|
||||
public void checkAnnotationsPresent() {
|
||||
Function<Test<? extends Annotation>, Annotation> mapper = this::getAnnotation;
|
||||
Function<Test<? extends Annotation>, ? extends Annotation> mapper1 = this::getAnnotation;
|
||||
}
|
||||
|
||||
public <A extends Annotation> A getAnnotation(Test<A> annotationClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class Annotation{}
|
||||
|
||||
|
||||
}
|
||||
+4
@@ -310,6 +310,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWildcardParametrization() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user