public List<Type> intersect(List<Type> cl1, List<Type> cl2) {
        if (cl1 == cl2)
            return cl1;
        if (cl1.isEmpty() || cl2.isEmpty())
            return List.nil();
        if (cl1.head.tsym.precedes(cl2.head.tsym, this))
            return intersect(cl1.tail, cl2);
        if (cl2.head.tsym.precedes(cl1.head.tsym, this))
            return intersect(cl1, cl2.tail);
        if (isSameType(cl1.head, cl2.head))
            return intersect(cl1.tail, cl2.tail).prepend(cl1.head);
        if (cl1.head.tsym == cl2.head.tsym &&
            cl1.head.hasTag(CLASS) && cl2.head.hasTag(CLASS)) {
            if (cl1.head.isParameterized() && cl2.head.isParameterized()) {
                Type merge = merge(cl1.head,cl2.head);
                return intersect(cl1.tail, cl2.tail).prepend(merge);
            }
            if (cl1.head.isRaw() || cl2.head.isRaw())
                return intersect(cl1.tail, cl2.tail).prepend(erasure(cl1.head));
        }
        return intersect(cl1.tail, cl2.tail);
    }
public List < Type > intersect ( List < Type > cl1 , List < Type > cl2 ) { if ( cl1 == cl2 ) return cl1 ; if ( cl1 . isEmpty ( ) || cl2 . isEmpty ( ) ) return List . nil ( ) ; if ( cl1 . head . tsym . precedes ( cl2 . head . tsym , this ) ) return intersect ( cl1 . tail , cl2 ) ; if ( cl2 . head . tsym . precedes ( cl1 . head . tsym , this ) ) return intersect ( cl1 , cl2 . tail ) ; if ( isSameType ( cl1 . head , cl2 . head ) ) return intersect ( cl1 . tail , cl2 . tail ) . prepend ( cl1 . head ) ; if ( cl1 . head . tsym == cl2 . head . tsym && cl1 . head . hasTag ( CLASS ) && cl2 . head . hasTag ( CLASS ) ) { if ( cl1 . head . isParameterized ( ) && cl2 . head . isParameterized ( ) ) { Type merge = merge ( cl1 . head , cl2 . head ) ; return intersect ( cl1 . tail , cl2 . tail ) . prepend ( merge ) ; } if ( cl1 . head . isRaw ( ) || cl2 . head . isRaw ( ) ) return intersect ( cl1 . tail , cl2 . tail ) . prepend ( erasure ( cl1 . head ) ) ; } return intersect ( cl1 . tail , cl2 . tail ) ; }
Intersect two closures