[Nice-commit] Nice/src/bossa/syntax Pattern.java,1.91,1.92 MethodBodyDefinition.java,1.151,1.152
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-09-15 00:47:43
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6980/src/bossa/syntax Modified Files: Pattern.java MethodBodyDefinition.java Log Message: Take into account nullness when find which method an implementation belongs to. Always report the precise pattern that prevents an implementation from belonging to a method, when there is no ambiguity about which method is concerned. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** Pattern.java 7 Aug 2004 14:20:29 -0000 1.91 --- Pattern.java 15 Sep 2004 00:47:31 -0000 1.92 *************** *** 198,225 **** } } ! ! static void inDomain(Pattern[] patterns, Monotype[] types) throws TypingEx { ! for (int i = 0; i < patterns.length; i++) ! Types.setMarkedKind(types[i]); ! for (int i = 0; i < patterns.length; i++) ! patterns[i].inDomain(Types.rawType(types[i])); ! } - private void inDomain(Monotype type) throws TypingEx - { if (constraint != null) { constraint.enter(); ! Typing.leq(patternType, type); } else { ! Typing.leq(tc, type); } if (tc2 != null) ! Typing.leq(tc2, type); } --- 198,223 ---- } } ! ! void inDomain(Monotype type) throws TypingEx { ! Types.setMarkedKind(type); ! if (this.atNull()) ! Typing.leq(PrimitiveType.maybeTC, type.head()); ! ! Monotype rawType = Types.rawType(type); if (constraint != null) { constraint.enter(); ! Typing.leq(patternType, rawType); } else { ! Typing.leq(tc, rawType); } if (tc2 != null) ! Typing.leq(tc2, rawType); } Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** MethodBodyDefinition.java 7 Aug 2004 14:20:28 -0000 1.151 --- MethodBodyDefinition.java 15 Sep 2004 00:47:31 -0000 1.152 *************** *** 129,132 **** --- 129,136 ---- hasAdditionalTags = true; + // 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();){ VarSymbol s = (VarSymbol)i.next(); *************** *** 136,140 **** continue; } ! MethodDeclaration m = s.getMethodDeclaration(); if (m.isIgnored()) --- 140,144 ---- continue; } ! MethodDeclaration m = s.getMethodDeclaration(); if (m.isIgnored()) *************** *** 150,154 **** continue; } ! try{ int level; --- 154,158 ---- continue; } ! try{ int level; *************** *** 162,166 **** mlsub.typing.Polytype t = m.getType(); Constraint.enter(t.getConstraint()); ! Pattern.inDomain(formals, t.domain()); } finally{ --- 166,184 ---- mlsub.typing.Polytype t = m.getType(); Constraint.enter(t.getConstraint()); ! Monotype[] domain = t.domain(); ! for (int p = 0; p < domain.length; p++) ! try { ! formals[p].inDomain(domain[p]); ! } ! catch (TypingEx e) { ! if (error == null) ! error = new UserError(formals[p], ! "Pattern " + formals[p] + ! " is incompatible with " + domain[p]); ! else ! multipleErrors = true; ! ! throw e; ! } } finally{ *************** *** 245,255 **** bossa.syntax.dispatch.removeNonMinimal(symbols); ! if(symbols.size() == 1) return (VarSymbol) symbols.get(0); ! if(symbols.size()==0) ! User.error(this, ! "No method called " + name + ! " is compatible with these patterns"); String methods = ""; --- 263,278 ---- bossa.syntax.dispatch.removeNonMinimal(symbols); ! if(symbols.size() == 1) return (VarSymbol) symbols.get(0); ! if (symbols.size() == 0) ! { ! if (error != null && ! multipleErrors) ! throw error; ! else ! User.error(this, ! "No method called " + name + ! " is compatible with these patterns"); ! } String methods = ""; |