new inference: incorporation: proceed with capture incorporation if not all type args are wildcards

This commit is contained in:
Anna.Kozlova
2016-12-28 14:20:06 +01:00
parent ab08c979a5
commit 0e2a160436
@@ -126,6 +126,21 @@ public class InferenceIncorporationPhase {
LOG.assertTrue(gClass != null);
final InferenceVariable[] parameters = capture.first;
PsiType[] typeArgs = right.getParameters();
PsiSubstitutor restSubst = PsiSubstitutor.EMPTY;
if (Registry.is("javac.fresh.variables.for.captured.wildcards.only")) {
List<PsiType> args = new ArrayList<PsiType>();
PsiTypeParameter[] typeParameters = gClass.getTypeParameters();
for (int i = 0; i < typeArgs.length; i++) {
PsiType arg = typeArgs[i];
if (arg instanceof PsiWildcardType) {
args.add(arg);
}
else {
restSubst = restSubst.put(typeParameters[i], arg);
}
}
typeArgs = args.toArray(PsiType.EMPTY_ARRAY);
}
if (parameters.length != typeArgs.length) continue;
for (int i = 0; i < typeArgs.length; i++) {
final PsiType aType = typeArgs[i];
@@ -155,6 +170,8 @@ public class InferenceIncorporationPhase {
}
}
glb = restSubst.substitute(glb);
if (!((PsiWildcardType)aType).isBounded()) {
for (PsiType upperBound : upperBounds) {