[Nice-commit] Nice/src/mlsub/typing Variance.java,1.18,1.19 NullnessKind.java,1.7,1.8 MonotypeVar.ja
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2005-06-09 11:57:35
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20429/src/mlsub/typing Modified Files: Variance.java NullnessKind.java MonotypeVar.java Monotype.java Log Message: Better implementation of wildcards (fixes #1216727). Index: Variance.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Variance.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Variance.java 25 May 2005 23:22:57 -0000 1.18 --- Variance.java 9 Jun 2005 11:57:00 -0000 1.19 *************** *** 256,260 **** if (tp1[i].isUnknown()) { ! tp2[i].setUnknown(); continue; } --- 256,260 ---- if (tp1[i].isUnknown()) { ! tp2[i].setUnknown(true, true); continue; } Index: MonotypeVar.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/MonotypeVar.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MonotypeVar.java 27 May 2005 13:59:47 -0000 1.20 --- MonotypeVar.java 9 Jun 2005 11:57:00 -0000 1.21 *************** *** 201,213 **** } private boolean unknown; boolean isUnknown() { return unknown; } ! void setUnknown() throws mlsub.typing.lowlevel.Unsatisfiable { if (equivalent != null) ! equivalent.setUnknown(); equivalent = UnknownMonotype.instance; --- 201,251 ---- } + /** + True when this variable was created during the decomposition of T + into T0<T1,...> caused by a constraint A<B1,...> <: T + This a priori implies T1 = B1 (supposing A is invariant, but the + allowUnknown variable marks that T1=? (UnknownMonotype) is also a + valid solution. + */ + private boolean allowUnknown = false; + + /** + Allow this type's type parameters to be changed to the unknown type. + */ + public void allowUnknownTypeParameters() + { + if (equivalent instanceof MonotypeConstructor) + { + MonotypeVar[] tps = (MonotypeVar[]) ((MonotypeConstructor) equivalent).getTP(); + if (tps != null) + for (int i = 0; i < tps.length; i++) + { + tps[i].allowUnknown = true; + if (tps[i].equivalent != null) + tps[i].allowUnknownTypeParameters(); + } + } + } + private boolean unknown; boolean isUnknown() { return unknown; } ! void setUnknown(boolean leq, boolean geq) throws mlsub.typing.lowlevel.Unsatisfiable { if (equivalent != null) ! { ! if (persistentKind == null) ! { ! if (! allowUnknown) ! throw mlsub.typing.lowlevel.LowlevelUnsatisfiable.instance; ! } ! else ! { ! Monotype raw = ((MonotypeConstructor) equivalent()).getTP()[0]; ! raw.setUnknown(leq, geq); ! } ! } equivalent = UnknownMonotype.instance; Index: NullnessKind.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/NullnessKind.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** NullnessKind.java 31 May 2005 07:32:50 -0000 1.7 --- NullnessKind.java 9 Jun 2005 11:57:00 -0000 1.8 *************** *** 45,52 **** introduce(tc); ! Monotype raw = new MonotypeVar(existential); Typing.introduce(raw); ! return new MonotypeConstructor(tc, new Monotype[]{ raw }); } --- 45,52 ---- introduce(tc); ! MonotypeVar raw = new MonotypeVar(existential); Typing.introduce(raw); ! return new MonotypeConstructor(tc, new MonotypeVar[]{ raw }); } *************** *** 62,68 **** so that for the syntactic type <T> ... !T we don't end up printing !t9. */ ! Monotype raw = new MonotypeVar(base.getName()); ! return new MonotypeConstructor(tc, new Monotype[]{ raw }); } --- 62,68 ---- so that for the syntactic type <T> ... !T we don't end up printing !t9. */ ! MonotypeVar raw = new MonotypeVar(base.getName()); ! return new MonotypeConstructor(tc, new MonotypeVar[]{ raw }); } *************** *** 98,107 **** if (m1.isUnknown()) { ! m2.setUnknown(); return; } if (m2.isUnknown()) ! throw LowlevelUnsatisfiable.instance; MonotypeConstructor mc1 = mc(m1), mc2 = mc(m2); --- 98,110 ---- if (m1.isUnknown()) { ! m2.setUnknown(false, true); return; } if (m2.isUnknown()) ! { ! m1.setUnknown(true, false); ! return; ! } MonotypeConstructor mc1 = mc(m1), mc2 = mc(m2); Index: Monotype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Monotype.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Monotype.java 30 Jul 2004 19:08:45 -0000 1.11 --- Monotype.java 9 Jun 2005 11:57:00 -0000 1.12 *************** *** 123,131 **** boolean isUnknown() { return false; } ! void setUnknown() throws mlsub.typing.lowlevel.Unsatisfiable { ! mlsub.typing.lowlevel.Engine.leq ! (TopMonotype.instance, nice.tools.typing.Types.rawType(this)); } --- 123,137 ---- boolean isUnknown() { return false; } ! void setUnknown(boolean leq, boolean geq) throws mlsub.typing.lowlevel.Unsatisfiable { ! if (leq) ! throw mlsub.typing.lowlevel.LowlevelUnsatisfiable.instance; ! ! if (geq) ! { ! Monotype raw = nice.tools.typing.Types.rawType(this); ! mlsub.typing.lowlevel.Engine.leq(TopMonotype.instance, raw); ! } } |