diff -u -r ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/CClass.java compiler/src/at/dms/kjc/CClass.java --- ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/CClass.java Fri Mar 16 13:48:55 2001 +++ compiler/src/at/dms/kjc/CClass.java Fri Mar 16 19:08:09 2001 @@ -246,7 +246,7 @@ } /** - * Sets the super class of this class + * Sets the super class of this class. */ public void setSuperClass(CClassType superClass) { @@ -254,7 +254,7 @@ } /** - * Returns the type of this class + * Returns the type of this class. */ public CClassType getType() { @@ -265,7 +265,10 @@ } /** - * @return the source file of this class + * Returns the source file of this class. + * + * @return + * The source file of this class. */ public String getSourceFile() { @@ -273,8 +276,13 @@ } /** - * @param ident the name of the field - * @return the field + * Returns the named field. + * + * @param ident + * The name of the field to get. + * + * @return + * The field with the same name as the value of ident. */ public CField getField(String ident) { @@ -283,13 +291,18 @@ return fields.lookup(ident); } + /** + * Returns the number of fields in this class. + */ public int getFieldCount() { return fields.size(); } /** - * @return the InnerClasses + * Returns the InnerClasses of this clas. + * + * @return the InnerClasses. */ public CClassType[] getInnerClasses() { @@ -297,7 +310,7 @@ } /** - * End of first pass, we need innerclassesinterfaces + * End of first pass, we need inner classes/interfaces. */ public void setInnerClasses(CClassType[] inners) { @@ -491,12 +504,17 @@ } /** - * lookupMethod - * search for a matching method with the provided type parameters - * look in parent hierarchy as needed - * @param name method name - * @param params method parameters - * @exception UnpositionedError this error will be positioned soon + * Search for a matching method with the provided type parameters. + * look in parent hierarchy as needed. + * + * @param name + * Method name. + * + * @param params + * Method parameters. + * + * @exception UnpositionedError + * This error will be positioned soon. */ public CMethod lookupMethod(CClass caller, String name, CType[] params) throws UnpositionedError diff -u -r ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/CNumericType.java compiler/src/at/dms/kjc/CNumericType.java --- ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/CNumericType.java Fri Mar 16 13:48:55 2001 +++ compiler/src/at/dms/kjc/CNumericType.java Sat Mar 17 14:57:13 2001 @@ -214,11 +214,19 @@ */ public boolean isAssignableTo(CType dest) { + /* Each type is assignable to itself. */ if (dest == this) { return true; } if (dest.isNumeric()) { - /* short and char are not assignable to eachother. (JLS 5.1.2) */ + /* non-const byte (signed) is not assignable to a char (unsigned) + */ + if (type == TID_BYTE && dest.type == TID_CHAR) { + return false; + } + /* non-const short and char are not assignable to eachother. + * (JLS 5.1.2) + */ if (type == TID_SHORT || type == TID_CHAR) { return dest.type >= TID_INT; } diff -u -r ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/JClassDeclaration.java compiler/src/at/dms/kjc/JClassDeclaration.java --- ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/JClassDeclaration.java Fri Mar 16 13:48:55 2001 +++ compiler/src/at/dms/kjc/JClassDeclaration.java Fri Mar 16 19:03:58 2001 @@ -160,25 +160,25 @@ KjcMessages.MULTIPLE_ACCESS_MODIFIERS); CClass superClass = null; - CClassType type = null; + CClassType superType = null; if (superName == null) { if (getSourceClass().getType().equals(CStdType.Object)) { // java/lang/Object // superClass = null; - // type = null; + // superType = null; } else { superClass = CStdType.Object.getCClass(); - type = CStdType.Object; + superType = CStdType.Object; } } else { // find name try { - type = CClassType.lookup(superName); - type.checkType(context); - superClass = type.getCClass(); + superType = CClassType.lookup(superName); + superType.checkType(context); + superClass = superType.getCClass(); } catch (UnpositionedError cue) { /* This must be worked out further. To allow checks for @@ -188,7 +188,7 @@ // System.err.println("Strange delayed super class lookup: " // + superName); // not yet defined, throw cue.addPosition(getTokenReference()); - type = new CClassNameType(superName) { + superType = new CClassNameType(superName) { public void checkType(CContext ctxt) throws UnpositionedError { @@ -269,13 +269,15 @@ setInstanceInitializer(instanceInit); } - getCClass().setSuperClass(type); - super.checkInterface(context, type); + getCClass().setSuperClass(superType); + super.checkInterface(context, superType); } /** * Check that initializers are correct. - * @exception PositionedError an error with reference to the source file + * + * @exception PositionedError + * An error with reference to the source file. */ public void checkInitializers(CContext context) throws PositionedError diff -u -r ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/JNewAnonymousClassExpression.java compiler/src/at/dms/kjc/JNewAnonymousClassExpression.java --- ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/JNewAnonymousClassExpression.java Fri Mar 16 13:48:55 2001 +++ compiler/src/at/dms/kjc/JNewAnonymousClassExpression.java Fri Mar 16 19:09:42 2001 @@ -103,6 +103,12 @@ owner, owner.getQualifiedName() + "$"); decl.getCClass().setSynthetic(true); + /* Because this construct goes completely against the normal order + * of type checking, it is necessary to temporarily set the superclass + * with the following line, to allow the look for the superclass- + * constructor to find protected constructors. + */ + decl.getCClass().setSuperClass(type); // add implicit constructor JConstructorDeclaration cstr; @@ -121,7 +127,7 @@ null, type.toString(), argsTypes); } - CType[] parameters = superCstr.getParameters(); + CType[] parameters = superCstr.getParameters(); JFormalParameter[] fargs = new JFormalParameter[parameters.length]; CClassType[] throwables = superCstr.getThrowables(); diff -u -r ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/JTryCatchStatement.java compiler/src/at/dms/kjc/JTryCatchStatement.java --- ../KopiSusu-1.9b2-release/KopiSusu/compiler/src/at/dms/kjc/JTryCatchStatement.java Fri Mar 16 13:48:55 2001 +++ compiler/src/at/dms/kjc/JTryCatchStatement.java Fri Mar 16 18:55:53 2001 @@ -99,10 +99,15 @@ CClassType type = info.getThrowable(); for (int i = 0; i < catchClauses.length; i++) { - if (type.isAssignableTo(catchClauses[i].getType()) || - catchClauses[i].getType().isAssignableTo(type)) { + if ( type.isAssignableTo(catchClauses[i].getType()) || + catchClauses[i].getType().isAssignableTo(type)) { if (!catchClauses[i].isChecked()) { - isReachable |= checkClause(context, info.getContext(), + /* Don't pass info.getContext(); it contains variable + * declarations from the try clause that are invisible + * in the catch clause! -- EJB + */ + // isReachable|=checkClause(context, info.getContext(), + isReachable |= checkClause(context, unchecked, catchClauses[i], count++ == 0); } @@ -119,7 +124,6 @@ context.addThrowable(info); } - // CHECK ORDER $$$ WRONG WAY for (int i = 0; i < catchClauses.length; i++) { for (int j = i + 1; j < catchClauses.length; j++) { if (catchClauses[j].getType().