Skip to content
Permalink
Browse files

Fix compiler warnings on Scala 2.13

  • Loading branch information...
sirthias committed Jul 24, 2019
1 parent 67d16d2 commit 8c087c02cb1d6c1c48603db1d6e49a99902ad7f3
@@ -1,4 +1,4 @@
version = 2.0.0-RC5
version = 2.0.0

maxColumn = 120
assumeStandardLibraryStripMargin = true
@@ -41,8 +41,8 @@ sealed abstract class CharPredicate extends (Char => Boolean) {

def ++(char: Char): CharPredicate = this ++ (char :: Nil)
def --(char: Char): CharPredicate = this -- (char :: Nil)
def ++(chars: String): CharPredicate = this ++ chars.toCharArray
def --(chars: String): CharPredicate = this -- chars.toCharArray
def ++(chars: String): CharPredicate = this ++ chars.toIndexedSeq
def --(chars: String): CharPredicate = this -- chars.toIndexedSeq

def intersect(that: CharPredicate): CharPredicate

@@ -127,7 +127,7 @@ object CharPredicate {
object ApplyMagnet {
implicit def fromPredicate(predicate: Char => Boolean): ApplyMagnet = new ApplyMagnet(from(predicate))
implicit def fromChar(c: Char): ApplyMagnet = fromChars(c :: Nil)
implicit def fromCharArray(array: Array[Char]): ApplyMagnet = fromChars(array)
implicit def fromCharArray(array: Array[Char]): ApplyMagnet = fromChars(array.toIndexedSeq)
implicit def fromString(chars: String): ApplyMagnet = fromChars(chars)
implicit def fromChars(chars: Seq[Char]): ApplyMagnet =
chars match {
@@ -253,7 +253,7 @@ object CharPredicate {

def ++(that: CharPredicate): CharPredicate = that match {
case Empty => this
case x: ArrayBased => this ++ x.chars
case x: ArrayBased => this ++ x.chars.toIndexedSeq
case _ => this or that
}

@@ -263,7 +263,7 @@ object CharPredicate {

def --(that: CharPredicate): CharPredicate = that match {
case Empty => this
case x: ArrayBased => this -- x.chars
case x: ArrayBased => this -- x.chars.toIndexedSeq
case _ => this andNot that
}

@@ -491,8 +491,8 @@ trait OpTreeContext[OpTreeCtx <: ParserMacros.ParserContext] {
val base = op match {
case x: TerminalOpTree => q"org.parboiled2.RuleTrace.NotPredicate.Terminal(${x.ruleTraceTerminal})"
case x: RuleCall => q"org.parboiled2.RuleTrace.NotPredicate.RuleCall(${x.calleeNameTree})"
case x: StringMatch => q"""org.parboiled2.RuleTrace.NotPredicate.Named('"' + ${x.stringTree} + '"')"""
case x: IgnoreCaseString => q"""org.parboiled2.RuleTrace.NotPredicate.Named('"' + ${x.stringTree} + '"')"""
case x: StringMatch => q"""org.parboiled2.RuleTrace.NotPredicate.Named("\"" + ${x.stringTree} + '"')"""
case x: IgnoreCaseString => q"""org.parboiled2.RuleTrace.NotPredicate.Named("\"" + ${x.stringTree} + '"')"""
case x: Named => q"org.parboiled2.RuleTrace.NotPredicate.Named(${x.stringTree})"
case _ => q"org.parboiled2.RuleTrace.NotPredicate.Anonymous"
}
@@ -69,12 +69,15 @@ object CharPredicateSpec extends TestSuite {
}

def show(pred: CharPredicate): String = {
val chars = ('\u0000' to '\u0080').flatMap(c => if (pred(c)) Some(c) else None).toArray
val chars = ('\u0000' to '\u0080').flatMap(c => Some(c) filter pred).toArray
new String(chars)
}

def inspectMask(pred: CharPredicate) = {
val CharPredicate.MaskBased(lowMask, highMask) = pred
val (lowMask, highMask) = pred match {
case CharPredicate.MaskBased(a, b) => a -> b
case _ => throw new IllegalStateException()
}
"%016x|%016x" format (lowMask, highMask)
}
}

0 comments on commit 8c087c0

Please sign in to comment.
You can’t perform that action at this time.