private List<Pair<Type, Type>> getParameterizedSupers(Type t, Type s) {
        Type lubResult = types.lub(t, s);
        if (lubResult == syms.errType || lubResult == syms.botType) {
            return List.nil();
        }
        List<Type> supertypesToCheck = lubResult.isIntersection() ?
                ((IntersectionClassType)lubResult).getComponents() :
                List.of(lubResult);
        ListBuffer<Pair<Type, Type>> commonSupertypes = new ListBuffer<>();
        for (Type sup : supertypesToCheck) {
            if (sup.isParameterized()) {
                Type asSuperOfT = asSuper(t, sup);
                Type asSuperOfS = asSuper(s, sup);
                commonSupertypes.add(new Pair<>(asSuperOfT, asSuperOfS));
            }
        }
        return commonSupertypes.toList();
    }
private List < Pair < Type , Type > > getParameterizedSupers ( Type t , Type s ) { Type lubResult = types . lub ( t , s ) ; if ( lubResult == syms . errType || lubResult == syms . botType ) { return List . nil ( ) ; } List < Type > supertypesToCheck = lubResult . isIntersection ( ) ? ( ( IntersectionClassType ) lubResult ) . getComponents ( ) : List . of ( lubResult ) ; ListBuffer < Pair < Type , Type > > commonSupertypes = new ListBuffer < > ( ) ; for ( Type sup : supertypesToCheck ) { if ( sup . isParameterized ( ) ) { Type asSuperOfT = asSuper ( t , sup ) ; Type asSuperOfS = asSuper ( s , sup ) ; commonSupertypes . add ( new Pair < > ( asSuperOfT , asSuperOfS ) ) ; } } return commonSupertypes . toList ( ) ; }
/* If for two types t and s there is a least upper bound that contains
parameterized types G1, G2 ... Gn, then there exists supertypes of 't' of the form
G1<T1, ..., Tn>, G2<T1, ..., Tn>, ... Gn<T1, ..., Tn> and supertypes of 's' of the form
G1<S1, ..., Sn>, G2<S1, ..., Sn>, ... Gn<S1, ..., Sn> which will be returned by this method.
If no such common supertypes exists then an empty list is returned.

As an example for the following input:

t = java.util.ArrayList<java.lang.String>
s = java.util.List<T>

we get this ouput (singleton list):

[Pair[java.util.List<java.lang.String>,java.util.List<T>]]