From cc5db5f0508b28f790eff92922ca77331521223e Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Fri, 4 Dec 2020 12:24:17 -0800 Subject: [PATCH 1/3] support Scala 3.0.0-M2, and including Scala.js now --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f0e95c5..3065c5aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ import: scala/scala-dev:travis/default.yml language: scala scala: - - 3.0.0-M1 + - 3.0.0-M2 - 2.11.12 - 2.12.12 - 2.13.3 @@ -16,9 +16,6 @@ env: - ADOPTOPENJDK=11 SCALAJS_VERSION= matrix: - exclude: - - scala: 3.0.0-M1 - env: ADOPTOPENJDK=8 SCALAJS_VERSION=1.3.1 include: - scala: 2.11.12 env: ADOPTOPENJDK=8 SCALANATIVE_VERSION=0.3.9 From 1397fc29f6e226b630866dc2b44e6823ee915386 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Fri, 4 Dec 2020 12:26:06 -0800 Subject: [PATCH 2/3] upgrade to Scala 2.13.4 --- .travis.yml | 2 +- build.sbt | 3 +++ .../main/scala/scala/util/parsing/combinator/Parsers.scala | 4 +++- .../scala/util/parsing/combinator/PackratParsersTest.scala | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3065c5aa..a84fbe65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ scala: - 3.0.0-M2 - 2.11.12 - 2.12.12 - - 2.13.3 + - 2.13.4 env: - ADOPTOPENJDK=8 SCALAJS_VERSION= diff --git a/build.sbt b/build.sbt index dc331943..ab6e6404 100644 --- a/build.sbt +++ b/build.sbt @@ -13,6 +13,9 @@ lazy val parserCombinators = crossProject(JVMPlatform, JSPlatform, NativePlatfor libraryDependencies += "junit" % "junit" % "4.13.1" % Test, libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, + // so we can `@nowarn` in test code, but only in test code, so the dependency + // doesn't leak downstream + libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.3.1" % Test, apiMappings ++= scalaInstance.value.libraryJars.collect { case file if file.getName.startsWith("scala-library") && file.getName.endsWith(".jar") => diff --git a/shared/src/main/scala/scala/util/parsing/combinator/Parsers.scala b/shared/src/main/scala/scala/util/parsing/combinator/Parsers.scala index 35ee15e6..fbb712e7 100644 --- a/shared/src/main/scala/scala/util/parsing/combinator/Parsers.scala +++ b/shared/src/main/scala/scala/util/parsing/combinator/Parsers.scala @@ -403,7 +403,9 @@ trait Parsers { val res1 = Parser.this(in) val res2 = q(in) - (res1, res2) match { + // compiler thinks match isn't exhaustive; perhaps it's right, but does that mean there's a bug here? + // that's not clear to me, so for now let's just `@unchecked` it + ((res1, res2): @unchecked) match { case (s1 @ Success(_, next1), s2 @ Success(_, next2)) => if (next2.pos < next1.pos || next2.pos == next1.pos) s1 else s2 case (s1 @ Success(_, _), _) => s1 case (_, s2 @ Success(_, _)) => s2 diff --git a/shared/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala b/shared/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala index f95d45ec..6c9e28e2 100644 --- a/shared/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala +++ b/shared/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala @@ -190,7 +190,8 @@ private object grammars3 extends StandardTokenParsers with PackratParsers { | success(Nil) ) + @annotation.nowarn // Some(xs) in pattern isn't exhaustive def repMany1[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = - p~opt(repMany(p,q))~q ^^ {case x~Some(xs)~y => x::xs:::(y::Nil)} + p~opt(repMany(p,q))~q ^^ {case x~Some(xs)~y => x::xs:::(y::Nil)} } From df92b0868d45ea33cbac13414d9e78db83c3ff63 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Fri, 4 Dec 2020 12:26:29 -0800 Subject: [PATCH 3/3] minor code improvement context: scala/scala#9303, but even if that never goes anywhere, this still seems like code improvement to me so we might as well --- .../scala/scala/util/parsing/combinator/PackratParsers.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/main/scala/scala/util/parsing/combinator/PackratParsers.scala b/shared/src/main/scala/scala/util/parsing/combinator/PackratParsers.scala index 23a492d8..8db59f1d 100644 --- a/shared/src/main/scala/scala/util/parsing/combinator/PackratParsers.scala +++ b/shared/src/main/scala/scala/util/parsing/combinator/PackratParsers.scala @@ -211,7 +211,7 @@ to update each parser involved in the recursion. case LR(seed ,rule, Some(head)) => if(head.getHead != p) /*not head rule, so not growing*/ seed.asInstanceOf[ParseResult[T]] else { - in.updateCacheAndGet(p, MemoEntry(Right[LR, ParseResult[T]](seed.asInstanceOf[ParseResult[T]]))) + in.updateCacheAndGet(p, MemoEntry(Right(seed.asInstanceOf[ParseResult[T]]))) seed match { case f@Failure(_,_) => f case e@Error(_,_) => e