[Nice-commit] Nice/src/bossa/syntax MethodBodyDefinition.java,1.152,1.153
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-10-11 12:34:43
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10104/src/bossa/syntax Modified Files: MethodBodyDefinition.java Log Message: Give an explicit error message when an implementation is rejected because it uses a wrong parameter name. Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.152 retrieving revision 1.153 diff -C2 -d -r1.152 -r1.153 *** MethodBodyDefinition.java 15 Sep 2004 00:47:31 -0000 1.152 --- MethodBodyDefinition.java 11 Oct 2004 12:34:27 -0000 1.153 *************** *** 115,119 **** } ! /** Returns the symbol of the method this declaration belongs to. */ --- 115,139 ---- } ! private static class ErrorList ! { ! private List errors = null; ! boolean multipleErrors = false; ! ! void add(MethodDeclaration method, UserError error) ! { ! if (errors == null) ! errors = new ArrayList(); ! ! errors.add(error); ! } ! ! void report() ! { ! if (errors != null && errors.size() == 1) ! throw (UserError) errors.get(0); ! } ! } ! ! /** Returns the symbol of the method this declaration belongs to. */ *************** *** 130,135 **** // Try to remember what caused the error when no symbol could be found. ! UserError error = null; ! boolean multipleErrors = false; for(Iterator i = symbols.iterator(); i.hasNext();){ --- 150,154 ---- // Try to remember what caused the error when no symbol could be found. ! ErrorList errorList = new ErrorList(); for(Iterator i = symbols.iterator(); i.hasNext();){ *************** *** 172,181 **** } catch (TypingEx e) { ! if (error == null) ! error = new UserError(formals[p], ! "Pattern " + formals[p] + ! " is incompatible with " + domain[p]); ! else ! multipleErrors = true; throw e; --- 191,199 ---- } catch (TypingEx e) { ! errorList.add ! (m, ! new UserError(formals[p], ! "Pattern " + formals[p] + ! " is incompatible with " + domain[p])); throw e; *************** *** 199,203 **** * then try to find the most specific declaration(s) using these tc's * TODO: combine this code with removeNonMinimal in OverloadedSymbolExp ! */ if (symbols.size() > 1 && hasAdditionalTags) { --- 217,221 ---- * then try to find the most specific declaration(s) using these tc's * TODO: combine this code with removeNonMinimal in OverloadedSymbolExp ! */ if (symbols.size() > 1 && hasAdditionalTags) { *************** *** 255,258 **** --- 273,280 ---- if (formals[i].atAny() && formals[i].name != null && params.getName(i) != null && !formals[i].name.toString().equals(params.getName(i).toString())) { + errorList.add(m, + new UserError(formals[i], "Parameter " + formals[i] + + " should be called " + + params.getName(i))); it.remove(); continue outer; *************** *** 268,277 **** if (symbols.size() == 0) { ! if (error != null && ! multipleErrors) ! throw error; ! else ! User.error(this, ! "No method called " + name + ! " is compatible with these patterns"); } --- 290,299 ---- if (symbols.size() == 0) { ! errorList.report(); ! ! // Default message in case we could not produce a better one. ! User.error(this, ! "No method called " + name + ! " is compatible with these patterns"); } |