Reputation: 2339
Why self symbol is not recognized in here? I'm using Scala 2.12.
trait Parsers[ParseError, Parser[+_]] {
def or[A](s1: Parser[A], s2: Parser[A]): Parser[A]
case class ParserOps[A](p: Parser[A]) {
def |[B>:A](p2: Parser[B]): Parser[B] = self.or(p,p2)
def or[B>:A](p2: => Parser[B]): Parser[B] = self.or(p,p2)
}
}
Upvotes: 0
Views: 166
Reputation: 33637
You haven't defined self
. Define it and it will work.
trait Parsers[ParseError, Parser[+_]] { self =>
def or[A](s1: Parser[A], s2: Parser[A]): Parser[A]
case class ParserOps[A](p: Parser[A]) {
def |[B>:A](p2: Parser[B]): Parser[B] = self.or(p,p2)
def or[B>:A](p2: => Parser[B]): Parser[B] = self.or(p,p2)
}
}
Upvotes: 5