Skip to content

Commit

Permalink
Add evidence of subtyping to Match visitor method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmay committed Feb 17, 2022
1 parent 80561fb commit 8dac009
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core-v1/src/main/scala/algebra/Expr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ object Expr {
def visitMatch[I, S, B : ExtractValue.AsBoolean, O](
expr: Match[I, S, B, O, OP],
)(implicit
ev: S <:< I,
opO: OP[Option[O]],
): I ~:> Option[O]

Expand Down Expand Up @@ -514,6 +515,7 @@ object Expr {
override def visitMatch[I, S, B : ExtractValue.AsBoolean, O](
expr: Match[I, S, B, O, OP],
)(implicit
ev: S <:< I,
opO: OP[Option[O]],
): H[I, Option[O]] =
proxy(underlying.visitMatch(expr))
Expand Down Expand Up @@ -1317,6 +1319,7 @@ object Expr {
branches: IndexedSeq[MatchCase[I, _ <: S, B, O, OP]],
override private[v1] val debugging: Debugging[Nothing, Nothing] = NoDebugging,
)(implicit
ev: S <:< I,
opO: OP[Option[O]],
) extends Expr[I, Option[O], OP]("matching") {
override def visit[G[-_, +_]](v: Visitor[G, OP]): G[I, Option[O]] = v.visitMatch(this)
Expand Down
1 change: 1 addition & 0 deletions core-v1/src/main/scala/engine/ImmutableCachingEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ object ImmutableCachingEngine {
override def visitMatch[I, S, B : AsBoolean, O](
expr: Expr.Match[I, S, B, O, OP],
)(implicit
ev: S <:< I,
opO: OP[Option[O]],
): I => CachedResult[Option[O]] = memoize(expr, _) { i =>
val CachedResult(maybeMatch, cacheState) =
Expand Down
1 change: 1 addition & 0 deletions core-v1/src/main/scala/engine/SimpleEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ object SimpleEngine {
override def visitMatch[I, S, B : ExtractValue.AsBoolean, O](
expr: Expr.Match[I, S, B, O, OP],
)(implicit
ev: S <:< I,
opO: OP[Option[O]],
): I => Option[O] = { i =>
val maybeMatch = expr.branches.zipWithIndex.foldLeft(None: Option[(O, Int)]) {
Expand Down
1 change: 1 addition & 0 deletions core-v1/src/main/scala/engine/StandardEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ object StandardEngine {
override def visitMatch[I, S, B : ExtractValue.AsBoolean, O](
expr: Expr.Match[I, S, B, O, OP],
)(implicit
ev: S <:< I,
opO: OP[Option[O]],
): PO <:< I => ExprResult[PO, I, Option[O], OP] = ???

Expand Down

0 comments on commit 8dac009

Please sign in to comment.