[Nice-commit] Nice/src/bossa/syntax tools.nice,1.34,1.35 MethodDeclaration.java,1.57,1.58
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-03-26 00:47:30
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16395/src/bossa/syntax Modified Files: tools.nice MethodDeclaration.java Log Message: Make sure that existential type variables are confined to the typechecking of the current method (even if that one has not type variables itself). Index: tools.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/tools.nice,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** tools.nice 24 Mar 2004 18:19:50 -0000 1.34 --- tools.nice 26 Mar 2004 00:36:38 -0000 1.35 *************** *** 75,78 **** --- 75,83 ---- // If the type is polymorphic, we treat the type variables as soft: // we enter them in the context, so they are not generalized. + + // Make sure we are in a local typing context, so the new type variables + // are discarded when the typechecking of the current method is over. + MethodDeclaration.enterLocalContext(); + type.getConstraint.enter(true); } Index: MethodDeclaration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodDeclaration.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** MethodDeclaration.java 17 Mar 2004 16:55:34 -0000 1.57 --- MethodDeclaration.java 26 Mar 2004 00:36:38 -0000 1.58 *************** *** 186,190 **** { } ! void typecheck() { --- 186,205 ---- { } ! ! /** Whether typechecking is currently happening in the global context */ ! static boolean inGlobalContext = false; ! ! /** Make sure that we are in a local context, which will be discarded ! when typechecking this method is over. ! */ ! static void enterLocalContext() ! { ! if (! inGlobalContext) ! return; ! ! Typing.enter(); ! inGlobalContext = false; ! } ! void typecheck() { *************** *** 199,220 **** Polytype type = getType(); ! ! if (!Constraint.hasBinders(type.getConstraint())) ! { ! try{ ! innerTypecheck(); ! } ! catch(TypingEx e){ ! User.error(this, "Type error in method " + symbol.name); ! } ! return; ! } ! UserError error = null; try{ ! Typing.enter(); try{ ! type.getConstraint().enter(); try { --- 214,227 ---- Polytype type = getType(); ! UserError error = null; try{ ! if (Constraint.hasBinders(type.getConstraint())) ! Typing.enter(); ! else ! inGlobalContext = true; try{ ! Constraint.enter(type.getConstraint()); try { *************** *** 225,229 **** } finally{ ! Typing.leave(); } } --- 232,239 ---- } finally{ ! if (! inGlobalContext) ! Typing.leave(); ! else ! inGlobalContext = false; } } *************** *** 231,237 **** // If we got an earlier error, it's preferable to report that one. if (error == null) ! User.error(this, ! "The type of method " + symbol.name + ! " is not well formed: " + type + "\n" + e); } if (error != null) --- 241,250 ---- // If we got an earlier error, it's preferable to report that one. if (error == null) ! if (Constraint.hasBinders(type.getConstraint())) ! User.error(this, ! "The type of method " + symbol.name + ! " is not well formed: " + type + "\n" + e); ! else ! User.error(this, "Type error in method " + symbol.name); } if (error != null) |