[Nice-commit] Nice/src/bossa/syntax OverloadedSymbolExp.java,1.62,1.63
Brought to you by:
bonniot
From: <ar...@us...> - 2004-01-17 20:59:54
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv2306/F:/nice/src/bossa/syntax Modified Files: OverloadedSymbolExp.java Log Message: Fixed overloading resolving for function object symbols. Index: OverloadedSymbolExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/OverloadedSymbolExp.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** OverloadedSymbolExp.java 9 Dec 2003 15:21:05 -0000 1.62 --- OverloadedSymbolExp.java 17 Jan 2004 20:59:51 -0000 1.63 *************** *** 233,236 **** --- 233,254 ---- return res; + if (Types.domain(expectedType) != null) + { // in case of function objects symbols find the most precise match + List nonMin = removeNonMinimal(symbols); + if (symbols.size() == 1) + { + VarSymbol s = (VarSymbol) symbols.get(0); + Polytype symType = s.getClonedType(); + s.releaseClonedType(); + symbols = nonMin; + return uniqueExpression(s, symType); + } + else + symbols.addAll(nonMin); + } + + if (symbols.size() != 0) + throw new AmbiguityError(); + throw User.error(this, noMatchError(removed, expectedType)); } *************** *** 262,265 **** --- 280,286 ---- return res; + if (symbols.size() != 0) + throw new AmbiguityError(); + throw User.error(this, "No variable or field in this class has name " + ident); *************** *** 291,297 **** } - if (symbols.size() != 0) - throw new AmbiguityError(); - // There is no solution. return null; --- 312,315 ---- *************** *** 310,318 **** } ! static void removeNonMinimal(List symbols) { // optimization if(symbols.size()<2) ! return; int len = symbols.size(); --- 328,337 ---- } ! static List removeNonMinimal(List symbols) { + List removed = new ArrayList(); // optimization if(symbols.size()<2) ! return removed; int len = symbols.size(); *************** *** 361,366 **** --- 380,388 ---- Debug.println("Removing " + syms[i] + " since it is not minimal"); + removed.add(syms[i]); symbols.remove(syms[i]); } + + return removed; } |