*/
private static Type[] compress(Type... types) {
int n=types.length;
int found=0;
for (int i=0; i<n; i++) {
Type t=types[i];
if ((t==null)||(t instanceof Nothing)) {
types[i]=null;
continue;
}
found++;
for (int j=0; j<i; j++) {
// try to eliminate already contained types
Type jt=types[j];
if ((jt!=null)&&jt.contains(t)) {
types[i]=null;
found--;
break;
}
}
}
if (found==n) return types; // no compression needed
Type[] nts=new Type[found];
found=0;
for (int i=0; i<n; i++) {
Type t=types[i];
if (t==null) continue;
nts[found++]=t;
}
if (found!=nts.length) throw new RuntimeException("This shouldn't happen! found="+found+ " nts.length="+nts.length);
return nts;