+ if (possiblesuper.isClass()&&
+ cd2.isClass())
+ return isSuperorType(possiblesuper.getClassDesc(), cd2.getClassDesc());
+ else if (possiblesuper.isClass()&&
+ cd2.isNull())
+ return true;
+ else if (possiblesuper.isNull())
+ throw new Error(); //not sure when this case would occur
+ else if (possiblesuper.isPrimitive()&&
+ cd2.isPrimitive()) {
+ ///Primitive widenings from 5.1.2
+ if (cd2.isByte()&&(possiblesuper.isByte()||possiblesuper.isShort()||
+ possiblesuper.isInt()||possiblesuper.isLong()||
+ possiblesuper.isFloat()||possiblesuper.isDouble()))
+ return true;
+ if (cd2.isShort()&&(possiblesuper.isShort()||
+ possiblesuper.isInt()||possiblesuper.isLong()||
+ possiblesuper.isFloat()||possiblesuper.isDouble()))
+ return true;
+ if (cd2.isChar()&&(possiblesuper.isChar()||
+ possiblesuper.isInt()||possiblesuper.isLong()||
+ possiblesuper.isFloat()||possiblesuper.isDouble()))
+ return true;
+ if (cd2.isInt()&&(possiblesuper.isInt()||possiblesuper.isLong()||
+ possiblesuper.isFloat()||possiblesuper.isDouble()))
+ return true;
+ if (cd2.isLong()&&(possiblesuper.isLong()||
+ possiblesuper.isFloat()||possiblesuper.isDouble()))
+ return true;
+ if (cd2.isFloat()&&(possiblesuper.isFloat()||possiblesuper.isDouble()))
+ return true;
+ if (cd2.isDouble()&&possiblesuper.isDouble())
+
+ return true;
+ if (cd2.isBoolean()&&possiblesuper.isBoolean())
+ return true;
+
+ return false;
+ } else if (possiblesuper.isPrimitive()&&(!possiblesuper.isArray())&&
+ cd2.isPtr())
+ return false;
+ else if (cd2.isPrimitive()&&(!cd2.isArray())&&
+ possiblesuper.isPtr())
+ return false;
+ else
+ throw new Error("Case not handled:"+possiblesuper+" "+cd2);
+ }
+
+ public TypeDescriptor mostSpecific(TypeDescriptor td1, TypeDescriptor td2) {
+ if( isSuperorType( td1, td2 ) ) {
+ return td2;
+ }
+ if( isSuperorType( td2, td1 ) ) {
+ return td1;
+ }
+ throw new Error( td1+" and "+td2+" have no superclass relationship" );
+ }
+
+ public TypeDescriptor mostSpecific(TypeDescriptor td1, TypeDescriptor td2, TypeDescriptor td3) {
+ return mostSpecific( td1, mostSpecific( td2, td3 ) );
+ }
+
+ public boolean isSuperorType(ClassDescriptor possiblesuper, ClassDescriptor cd2) {
+ if (possiblesuper==cd2)
+ return true;
+ else
+ return isSuper(possiblesuper, cd2);
+ }
+
+ private boolean isSuper(ClassDescriptor possiblesuper, ClassDescriptor cd2) {
+
+ while(cd2!=null) {
+ cd2=getSuper(cd2);
+ if (cd2==possiblesuper)
+ return true;