Skip to content

Commit 1141efb

Browse files
committed
worked around scala/scala3#6142
1 parent 7e3b465 commit 1141efb

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/main/scala/Polyparse.scala

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,24 @@ case class BlockCompiler[ET:Type,Result](seqCtx : SequenceContext[ET]) {
137137
))
138138
) ++ computeBlocks(l) ++ computeBlocks(r)
139139
case Sequence(l, r) => {
140-
implicit val _ = l.tType
141-
implicit val _1 = r.tType
142-
type LT = l.t
143-
type RT = r.t
144-
Seq(
145-
(g, SeqIR(
146-
PreserveArgIR(CallIR[AT,LT](l)),
147-
SeqIR(
148-
PreserveArgIR(SeqIR(
149-
SimpleIR[(AT,LT),AT](ctx => ctx.succeed('{${ctx.arg} match { case (in,_) => in }})),
150-
CallIR[AT,RT](r)
151-
)),
152-
SimpleIR[((AT,LT),RT),(LT,RT)](ctx => ctx.succeed('{${ctx.arg} match { case ((_,res1),res2) => (res1,res2) }}))
153-
)
154-
)),
155-
) ++ computeBlocks(l) ++ computeBlocks(r)
140+
// this bizarre construct is a workaround to lampepfl/dotty#6142
141+
def fn[LT:Type,RT:Type](ll : Grammar[AT,LT,ET], rr : Grammar[AT,RT,ET]) = {
142+
val l = ll
143+
val r = rr
144+
Seq(
145+
(g, SeqIR(
146+
PreserveArgIR(CallIR[AT,LT](l)),
147+
SeqIR(
148+
PreserveArgIR(SeqIR(
149+
SimpleIR[(AT,LT),AT](ctx => ctx.succeed('{${ctx.arg} match { case (in,_) => in }})),
150+
CallIR[AT,RT](r)
151+
)),
152+
SimpleIR[((AT,LT),RT),(LT,RT)](ctx => ctx.succeed('{${ctx.arg} match { case ((_,res1),res2) => (res1,res2) }}))
153+
)
154+
)),
155+
) ++ computeBlocks(l) ++ computeBlocks(r)
156+
}
157+
fn(l,r)(l.tType,r.tType)
156158
}
157159
case Call(arg, fn) => {
158160
implicit val _ = arg.tType

0 commit comments

Comments
 (0)