@@ -2001,18 +2001,24 @@ private static boolean isAssignable(final Type type,
20012001
20022002 // now to check each type argument
20032003 for (final TypeVariable <?> var : toTypeVarAssigns .keySet ()) {
2004- final Type toTypeArg = unrollVariableAssignments (var , toTypeVarAssigns );
2005- final Type fromTypeArg = unrollVariableAssignments (var ,
2006- fromTypeVarAssigns );
2004+ Type toTypeArg = unrollVariableAssignments (var , toTypeVarAssigns );
2005+ final Type fromTypeArg = unrollVariableAssignments (var , fromTypeVarAssigns );
2006+
2007+ if (Types .containsTypeVars (toTypeArg ) && toTypeArg instanceof ParameterizedType ) {
2008+ Type [] toParameters = ((ParameterizedType ) toTypeArg ).getActualTypeArguments ();
2009+ Type [] toParamsResolved = Arrays .stream (toParameters )
2010+ .map (param -> typeVarAssigns .keySet ().contains (param ) ? typeVarAssigns .get (param ) : param )
2011+ .toArray (Type []::new );
2012+ toTypeArg = Types .parameterize (Types .raw (toTypeArg ), toParamsResolved );
2013+ }
20072014
20082015 // parameters must either be absent from the subject type, within
20092016 // the bounds of the wildcard type, or be an exact match to the
20102017 // parameters of the target type.
2011- if (fromTypeArg != null && !fromTypeArg .equals (toTypeArg ) &&
2012- !(toTypeArg instanceof WildcardType && isAssignable (fromTypeArg ,
2013- toTypeArg , typeVarAssigns )))
2014- {
2015- if (fromTypeArg instanceof Any ) continue ;
2018+ if (fromTypeArg != null && !fromTypeArg .equals (toTypeArg ) && !(toTypeArg instanceof WildcardType
2019+ && isAssignable (fromTypeArg , toTypeArg , typeVarAssigns ))) {
2020+ if (fromTypeArg instanceof Any )
2021+ continue ;
20162022 return false ;
20172023 }
20182024 }
0 commit comments