From 0e2a160436f5618d9d98e554805094717ecf2766 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Tue, 27 Dec 2016 20:19:13 +0100 Subject: [PATCH] new inference: incorporation: proceed with capture incorporation if not all type args are wildcards --- .../InferenceIncorporationPhase.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java index 3a4e80bda6dc..9b9cfa6b31d4 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java @@ -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 args = new ArrayList(); + 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) {