Skip to content

Commit

Permalink
InfixApp: define apply methods in companion
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 7, 2022
1 parent 88f54dc commit 7be8010
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ case class InfixApp(lhs: Tree, op: Name, rhs: Seq[Tree], all: Tree) {

object InfixApp {

def apply(t: Type.ApplyInfix): InfixApp = InfixApp(t.lhs, t.op, Seq(t.rhs), t)
def apply(t: Term.ApplyInfix): InfixApp = InfixApp(t.lhs, t.op, t.args, t)
def apply(t: Pat.ExtractInfix): InfixApp = InfixApp(t.lhs, t.op, t.rhs, t)

def unapply(tree: Tree): Option[InfixApp] =
tree match {
case t: Type.ApplyInfix => Some(InfixApp(t.lhs, t.op, Seq(t.rhs), t))
case t: Term.ApplyInfix => Some(InfixApp(t.lhs, t.op, t.args, t))
case t: Pat.ExtractInfix => Some(InfixApp(t.lhs, t.op, t.rhs, t))
case t: Type.ApplyInfix => Some(apply(t))
case t: Term.ApplyInfix => Some(apply(t))
case t: Pat.ExtractInfix => Some(apply(t))
case _ => None
}

Expand Down

0 comments on commit 7be8010

Please sign in to comment.