[Nice-commit] Nice/src/mlsub/typing Polytype.java,1.22,1.23 NullnessKind.java,1.3,1.4 MonotypeVar.ja
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-06-16 10:01:16
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32734/src/mlsub/typing Modified Files: Polytype.java NullnessKind.java MonotypeVar.java Log Message: Handle type variables that are used simultaneously with and without nullness markers (implements RFE #738496). Index: MonotypeVar.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/MonotypeVar.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** MonotypeVar.java 17 Mar 2004 16:55:34 -0000 1.16 --- MonotypeVar.java 16 Jun 2004 10:00:36 -0000 1.17 *************** *** 91,95 **** { res[i] = new MonotypeVar(existential); ! res[i].persistentKind = NullnessKind.instance; } return res; --- 91,95 ---- { res[i] = new MonotypeVar(existential); ! res[i].setPersistentKind(NullnessKind.instance); } return res; *************** *** 157,161 **** --- 157,169 ---- public void setPersistentKind(Kind k) { + if (persistentKind == k) + return; + persistentKind = k; + if (k == NullnessKind.instance) + { + kind = k; + equivalent = NullnessKind.instance.persistentFreshMonotype(); + } } *************** *** 165,176 **** { if (persistentKind == null) - setKind(null); - else { ! // Forget about the old equivalent. equivalent = null; kind = null; setKind(persistentKind); } } --- 173,200 ---- { if (persistentKind == null) { ! setKind(null); ! } ! else if (existential) ! { equivalent = null; kind = null; setKind(persistentKind); } + else if (equivalent != null) + { + if (persistentKind == NullnessKind.instance) + { + MonotypeConstructor mc = (MonotypeConstructor) equivalent(); + + TypeConstructor tc = mc.getTC(); + // Reassign a new id + NullnessKind.introduce(tc); + + MonotypeVar raw = (MonotypeVar) mc.getTP()[0]; + raw.reset(); + mlsub.typing.lowlevel.Engine.register(raw); + } + } } Index: NullnessKind.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/NullnessKind.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NullnessKind.java 17 Mar 2004 16:55:34 -0000 1.3 --- NullnessKind.java 16 Jun 2004 10:00:36 -0000 1.4 *************** *** 43,53 **** { TypeConstructor tc = new TypeConstructor(instance); ! Typing.introduce(tc); ! try { ! Typing.leq(tc, maybe); ! Typing.leq(sure, tc); ! } catch(TypingEx ex) { ! bossa.util.Internal.error("Nullness creation error"); ! } Monotype raw = new MonotypeVar(existential); --- 43,47 ---- { TypeConstructor tc = new TypeConstructor(instance); ! introduce(tc); Monotype raw = new MonotypeVar(existential); *************** *** 57,60 **** --- 51,73 ---- } + public Monotype persistentFreshMonotype() + { + TypeConstructor tc = new TypeConstructor(instance); + Monotype raw = new MonotypeVar(); + + return new MonotypeConstructor(tc, new Monotype[]{ raw }); + } + + static void introduce(TypeConstructor tc) + { + tc.getKind().register(tc); + try { + Typing.leq(tc, maybe); + Typing.leq(sure, tc); + } catch(TypingEx ex) { + bossa.util.Internal.error("Nullness creation error"); + } + } + public void register(Element e) { Index: Polytype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Polytype.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Polytype.java 26 Feb 2004 22:17:39 -0000 1.22 --- Polytype.java 16 Jun 2004 10:00:35 -0000 1.23 *************** *** 58,61 **** --- 58,70 ---- newBinders[i] = binders[i].cloneTypeSymbol(); map.put(binders[i], newBinders[i]); + // Clone the persistent equivalents of marked type variables. + if (binders[i] instanceof MonotypeVar && + ((MonotypeVar) binders[i]).persistentKind != null) + { + MonotypeConstructor mc = (MonotypeConstructor) ((MonotypeVar) binders[i]).equivalent(); + MonotypeConstructor nmc = (MonotypeConstructor) ((MonotypeVar) newBinders[i]).equivalent(); + map.put(mc.getTC(), nmc.getTC()); + map.put(mc.getTP()[0], nmc.getTP()[0]); + } } |