diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index ad2b1ff9..b36a8535 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -2,6 +2,10 @@ name: ci on: push: + branches: + - master + tags: + - '*' pull_request: branches: - master diff --git a/build.sc b/build.sc index 415b3444..6100a572 100644 --- a/build.sc +++ b/build.sc @@ -5,6 +5,7 @@ import scalanativelib._ import publish._ import mill.eval.Result import mill.modules.Jvm.createJar +import mill.scalalib.api.Util.isScala3 import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.9:0.1.1` import de.tobiasroeser.mill.vcs.version.VcsVersion import $ivy.`com.github.lolgab::mill-mima_mill0.9:0.0.6` @@ -47,12 +48,13 @@ object fastparse extends Module{ trait FastparseModule extends CommonCrossModule{ def ivyDeps = Agg( - ivy"com.lihaoyi::sourcecode::0.2.3", + ivy"com.lihaoyi::sourcecode::0.2.7", ivy"com.lihaoyi::geny::0.6.10" ) - def compileIvyDeps = Agg( - ivy"org.scala-lang:scala-reflect:${scalaVersion()}" - ) + def compileIvyDeps = + if(isScala3(crossScalaVersion)) Agg.empty[Dep] + else Agg(ivy"org.scala-lang:scala-reflect:$crossScalaVersion") + def generatedSources = T{ val dir = T.ctx().dest val file = dir/"fastparse"/"SequencerGen.scala" @@ -139,8 +141,7 @@ trait ExampleParseJvmModule extends CommonCrossModule{ def platformSegment = "jvm" def ivyDeps = super.ivyDeps() ++ Agg( ivy"net.sourceforge.cssparser:cssparser:0.9.18", - ivy"org.scala-lang:scala-compiler:${scalaVersion()}" - ) + ) ++ (if (isScala3(crossScalaVersion)) Agg.empty[Dep] else Agg(ivy"org.scala-lang:scala-compiler:$crossScalaVersion")) } } @@ -186,12 +187,11 @@ trait CommonCrossModule extends CrossScalaModule with PublishModule with Mima{ def platformSegment: String def millSourcePath = super.millSourcePath / os.up - def sources = T.sources( - millSourcePath / "src", - millSourcePath / s"src-$platformSegment" - ) - - + def sources = T.sources { super.sources() ++ + Seq( + millSourcePath / s"src-$platformSegment" + ).map(PathRef(_)) + } } trait CommonTestModule extends ScalaModule with TestModule.Utest{ @@ -200,8 +200,6 @@ trait CommonTestModule extends ScalaModule with TestModule.Utest{ ivy"com.lihaoyi::utest::0.7.10", ) -// def scalacOptions = T{ if (scalaVersion() == "2.12.10") Seq("-opt:l:method") else Nil } - def sources = T.sources( millSourcePath / "src", millSourcePath / s"src-$platformSegment" @@ -248,14 +246,13 @@ object perftests extends Module{ ) } - trait PerfTestModule extends ScalaModule with TestModule{ + trait PerfTestModule extends ScalaModule with TestModule.Utest{ def scalaVersion = "2.12.13" def scalacOptions = Seq("-opt:l:method") def resources = T.sources{ Seq(PathRef(perftests.millSourcePath / "resources")) ++ fastparse.jvm("2.12.13").test.resources() } - def testFrameworks = Seq("utest.runner.Framework") def ivyDeps = Agg( ivy"com.lihaoyi::utest::0.7.10", ivy"org.scala-lang:scala-compiler:${scalaVersion()}" diff --git a/fastparse/src/fastparse/internal/MacroImpls.scala b/fastparse/src-2/fastparse/internal/MacroImpls.scala similarity index 100% rename from fastparse/src/fastparse/internal/MacroImpls.scala rename to fastparse/src-2/fastparse/internal/MacroImpls.scala diff --git a/fastparse/src/fastparse/internal/RepImpls.scala b/fastparse/src-2/fastparse/internal/RepImpls.scala similarity index 100% rename from fastparse/src/fastparse/internal/RepImpls.scala rename to fastparse/src-2/fastparse/internal/RepImpls.scala diff --git a/fastparse/src/fastparse/package.scala b/fastparse/src-2/fastparse/package.scala similarity index 100% rename from fastparse/src/fastparse/package.scala rename to fastparse/src-2/fastparse/package.scala diff --git a/fastparse/src/fastparse/Implicits.scala b/fastparse/src/fastparse/Implicits.scala index 6dc82ece..3203efaf 100644 --- a/fastparse/src/fastparse/Implicits.scala +++ b/fastparse/src/fastparse/Implicits.scala @@ -46,7 +46,7 @@ object Implicits { } } trait LowPriRepeater{ - implicit def GenericRepeaterImplicit[T] = GenericRepeatedImplicit0.asInstanceOf[Repeater[T, Seq[T]]] + implicit def GenericRepeaterImplicit[T]: Repeater[T, Seq[T]] = GenericRepeatedImplicit0.asInstanceOf[Repeater[T, Seq[T]]] object GenericRepeatedImplicit0 extends Repeater[Any, Seq[Any]]{ type Acc = mutable.Buffer[Any] def initial = mutable.Buffer.empty[Any] @@ -67,7 +67,7 @@ object Implicits { } } trait LowPriOptioner{ - implicit def GenericOptionerImplicit[T] = GenericOptionerImplicit0.asInstanceOf[Optioner[T, Option[T]]] + implicit def GenericOptionerImplicit[T]: Optioner[T, Option[T]] = GenericOptionerImplicit0.asInstanceOf[Optioner[T, Option[T]]] object GenericOptionerImplicit0 extends Optioner[Any, Option[Any]]{ def none = None def some(value: Any) = Some(value) diff --git a/fastparse/src/fastparse/ParserInput.scala b/fastparse/src/fastparse/ParserInput.scala index 9a06e793..249d5003 100644 --- a/fastparse/src/fastparse/ParserInput.scala +++ b/fastparse/src/fastparse/ParserInput.scala @@ -28,7 +28,7 @@ object ParserInputSource extends ParserInputSourceLowPri { } trait ParserInputSourceLowPri{ - implicit def fromReadable[T](s: T)(implicit f: T => geny.Readable) = FromReadable( + implicit def fromReadable[T](s: T)(implicit f: T => geny.Readable): FromReadable = FromReadable( f(s), // Default bufferSize of 4096. Somewhat arbitrary, but doesn't seem to matter // much in benchmarks, e.g. on parsing `GenJSCode.scala`: @@ -53,8 +53,8 @@ trait ParserInputSourceLowPri{ } object ParserInput{ - implicit def fromString(s: String) = IndexedParserInput(s) - implicit def FromIterator(s: Iterator[String]) = IteratorParserInput(s) + implicit def fromString(s: String): IndexedParserInput = IndexedParserInput(s) + implicit def FromIterator(s: Iterator[String]): IteratorParserInput = IteratorParserInput(s) } /** * ParserInput class represents data that is needed to parse. diff --git a/fastparse/src/fastparse/Whitespace.scala b/fastparse/src/fastparse/Whitespace.scala index b02b188c..36a6f81d 100644 --- a/fastparse/src/fastparse/Whitespace.scala +++ b/fastparse/src/fastparse/Whitespace.scala @@ -18,7 +18,7 @@ object NoWhitespace { * characters. */ object SingleLineWhitespace { - implicit val whitespace = {implicit ctx: ParsingRun[_] => + implicit val whitespace: ParsingRun[_] => ParsingRun[Unit] = {implicit ctx: ParsingRun[_] => var index = ctx.index val input = ctx.input @@ -34,7 +34,7 @@ object SingleLineWhitespace { * "\r" and "\n" whitespace characters. */ object MultiLineWhitespace { - implicit val whitespace = {implicit ctx: ParsingRun[_] => + implicit val whitespace: ParsingRun[_] => ParsingRun[Unit] = {implicit ctx: ParsingRun[_] => var index = ctx.index val input = ctx.input @@ -51,7 +51,7 @@ object MultiLineWhitespace { * programming languages such as Bash, Ruby, or Python */ object ScriptWhitespace{ - implicit val whitespace = {implicit ctx: ParsingRun[_] => + implicit val whitespace: ParsingRun[_] => ParsingRun[Unit] = {implicit ctx: ParsingRun[_] => val input = ctx.input @tailrec def rec(current: Int, state: Int): ParsingRun[Unit] = { if (!input.isReachable(current)) ctx.freshSuccessUnit(current) @@ -78,7 +78,7 @@ object ScriptWhitespace{ * in the Java programming language */ object JavaWhitespace{ - implicit val whitespace = {implicit ctx: ParsingRun[_] => + implicit val whitespace: ParsingRun[_] => ParsingRun[Unit] = {implicit ctx: ParsingRun[_] => val input = ctx.input val startIndex = ctx.index @tailrec def rec(current: Int, state: Int): ParsingRun[Unit] = { @@ -128,7 +128,7 @@ object JavaWhitespace{ * case in the Jsonnet programming language */ object JsonnetWhitespace{ - implicit val whitespace = {implicit ctx: ParsingRun[_] => + implicit val whitespace: ParsingRun[_] => ParsingRun[Unit] = {implicit ctx: ParsingRun[_] => val input = ctx.input val startIndex = ctx.index @tailrec def rec(current: Int, state: Int): ParsingRun[Unit] = { @@ -178,7 +178,7 @@ object JsonnetWhitespace{ * in the Scala programming language */ object ScalaWhitespace { - implicit val whitespace = {implicit ctx: ParsingRun[_] => + implicit val whitespace: ParsingRun[_] => ParsingRun[Unit] = {implicit ctx: ParsingRun[_] => val input = ctx.input val startIndex = ctx.index @tailrec def rec(current: Int, state: Int, nesting: Int): ParsingRun[Unit] = { diff --git a/fastparse/src/fastparse/internal/Util.scala b/fastparse/src/fastparse/internal/Util.scala index 7115522a..340f3b20 100644 --- a/fastparse/src/fastparse/internal/Util.scala +++ b/fastparse/src/fastparse/internal/Util.scala @@ -107,7 +107,7 @@ class Lazy[T](calc0: () => T){ case class Logger(f: String => Unit) object Logger { - implicit val stdout = Logger(println) + implicit val stdout: Logger = Logger(println) } trait Instrument{