@@ -98,14 +98,17 @@ class ConstraintSolver(infVarState: InfVarUid.State, elState: Elaborator.State,
98
98
v.state.lowerBounds ::= bd
99
99
v.state.upperBounds.foreach(ub => constrainImpl(bd, ub))
100
100
v.state.disjsub.foreach: d =>
101
- Type .disjoint(d.disjoint(v), bd.toBasic.simp.toBasic)(Set .empty)(using c = mutable.Map .empty) match
102
- case N =>
103
- d.remove(v)
104
- if d.disjoint.isEmpty then
105
- d.dss.foreach(_.commit())
106
- d.cs.foreach((a, b) => constrainImpl(a, b))
107
- case S (k) =>
108
- k.foreach(k => DisjSub (d.disjoint ++ k, d.dss, d.cs).commit())
101
+ val u = d.disjoint(v).flatMap: t =>
102
+ Type .disjoint(t, bd.toBasic.simp.toBasic)(Set .empty)(using c = mutable.Map .empty)
103
+ if u.isEmpty then
104
+ d.remove(v)
105
+ if d.disjoint.isEmpty then
106
+ d.dss.foreach(_.commit())
107
+ d.cs.foreach((a, b) => constrainImpl(a, b))
108
+ else
109
+ d.clear()
110
+ u.reduce((x, y) => y.flatMap(y => x.map(_ ++ y))).foreach: k =>
111
+ DisjSub (mutable.Map .from(k.groupMap(_._1)(_._2)), d.dss, d.cs).commit()
109
112
case Conj (i, u, Nil ) => (conj.i, conj.u) match
110
113
case (_, Union (N , Nil )) =>
111
114
// raise(ErrorReport(msg"Cannot solve ${conj.i.toString()} ∧ ¬⊥" -> N :: Nil))
@@ -133,7 +136,7 @@ class ConstraintSolver(infVarState: InfVarUid.State, elState: Elaborator.State,
133
136
else
134
137
val cs = (ret1, ret2) :: (eff1, eff2) :: args2.zip(args1)
135
138
k.reduce((x, y) => y.flatMap(y => x.map(_ ++ y))).foreach: k =>
136
- DisjSub (mutable.Map .from(k), Nil , cs).commit()
139
+ DisjSub (mutable.Map .from(k.groupMap(_._1)(_._2) ), Nil , cs).commit()
137
140
case (Inter (S (fs: Ls [FunType ])), Union (S (FunType (args2, ret2, eff2)), Nil )) =>
138
141
val f = fs.filter(_.args.length === args2.length)
139
142
val args = f.map(_.args).transpose
@@ -152,7 +155,7 @@ class ConstraintSolver(infVarState: InfVarUid.State, elState: Elaborator.State,
152
155
constrainImpl(b.eff, eff2)
153
156
case S (k) =>
154
157
val cs = (b.ret,ret2) :: (b.eff,eff2) :: s
155
- k.foreach(k => DisjSub (mutable.Map .from(k), Nil , cs).commit())
158
+ k.foreach(k => DisjSub (mutable.Map .from(k.groupMap(_._1)(_._2) ), Nil , cs).commit())
156
159
case _ =>
157
160
// raise(ErrorReport(msg"Cannot solve ${conj.i.toString()} <: ${conj.u.toString()}" -> N :: Nil))
158
161
cctx.err
0 commit comments