Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparation work for Scala 3 #252

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: ci

on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
Expand Down
29 changes: 13 additions & 16 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"))
}
}

Expand Down Expand Up @@ -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{

Expand All @@ -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"
Expand Down Expand Up @@ -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()}"
Expand Down
4 changes: 2 additions & 2 deletions fastparse/src/fastparse/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions fastparse/src/fastparse/ParserInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand All @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions fastparse/src/fastparse/Whitespace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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)
Expand All @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down
2 changes: 1 addition & 1 deletion fastparse/src/fastparse/internal/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down