Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 230304c

Browse files
committed
Use -Xsource:3 and accommodate signature moves
1 parent 483b4ee commit 230304c

File tree

59 files changed

+312
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+312
-220
lines changed

build.sbt

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,15 @@ lazy val commonSettings = instanceSettings ++ clearSourceAndResourceDirectories
196196
cleanFiles += (Compile / doc / target).value,
197197
run / fork := true,
198198
run / connectInput := true,
199-
Compile / scalacOptions ++= Seq("-feature", "-Xlint",
199+
Compile / scalacOptions ++= Seq("-Xlint", "-feature", "-Xsource:3-cross",
200200
//"-Vprint",
201201
//"-Xmaxerrs", "5", "-Xmaxwarns", "5", // uncomment for ease of development while breaking things
202202
// work around https://github.com/scala/bug/issues/11534
203203
"-Wconf:cat=unchecked&msg=The outer reference in this type test cannot be checked at run time.:s",
204204
// optimizer warnings at INFO since `-Werror` may be turned on.
205205
// optimizer runs in CI and release builds, though not in local development.
206-
"-Wconf:cat=optimizer:is",
206+
//"-Wconf:cat=optimizer:is",
207+
"-Wopt",
207208
// we use @nowarn for methods that are deprecated in JDK > 8, but CI/release is under JDK 8
208209
"-Wconf:cat=unused-nowarn:s",
209210
"-Wunnamed-boolean-literal-strict",
@@ -450,6 +451,10 @@ lazy val library = configureAsSubproject(project)
450451
name := "scala-library",
451452
description := "Scala Standard Library",
452453
Compile / scalacOptions ++= Seq("-sourcepath", (Compile / scalaSource).value.toString),
454+
Compile / scalacOptions ++= Seq("-Xsource-features:-case-companion-function"),
455+
Compile / scalacOptions ++= Seq("-Wconf:cat=scala3-migration&msg=elidable&site=scala.Predef:s"),
456+
//Compile / scalacOptions ++= Seq("-Wconf:msg=Synthetic case companion&src=src/library/scala/jdk/FunctionWrappers.scala:s"),
457+
//Compile / scalacOptions ++= Seq("-Wconf:cat=scala3-migration&msg=constructor modifiers&site=scala.concurrent.duration.Deadline:s"), // for bootstrap until restarr
453458
Compile / doc / scalacOptions ++= {
454459
val libraryAuxDir = (ThisBuild / baseDirectory).value / "src/library-aux"
455460
Seq(
@@ -502,6 +507,7 @@ lazy val reflect = configureAsSubproject(project)
502507
Osgi.bundleName := "Scala Reflect",
503508
Compile / scalacOptions ++= Seq(
504509
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
510+
"-Wconf:cat=scala3-migration&msg=early initializers:s", // compiler heavily relies upon early initializers
505511
),
506512
Compile / doc / scalacOptions ++= Seq(
507513
"-skip-packages", "scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io"
@@ -576,6 +582,7 @@ lazy val compiler = configureAsSubproject(project)
576582
Compile / scalacOptions ++= Seq(
577583
//"-Wunused", //"-Wnonunit-statement",
578584
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
585+
"-Wconf:cat=scala3-migration&msg=early initializers:s", // compiler heavily relies upon early initializers
579586
),
580587
Compile / doc / scalacOptions ++= Seq(
581588
"-doc-root-content", (Compile / sourceDirectory).value + "/rootdoc.txt"
@@ -614,15 +621,21 @@ lazy val interactive = configureAsSubproject(project)
614621
.settings(
615622
name := "scala-compiler-interactive",
616623
description := "Scala Interactive Compiler",
617-
Compile / scalacOptions ++= Seq("-Wconf:cat=deprecation&msg=early initializers:s"),
624+
Compile / scalacOptions ++= Seq(
625+
"-Wconf:cat=deprecation&msg=early initializers:s",
626+
"-Wconf:cat=scala3-migration&msg=early initializers:s", // compiler heavily relies upon early initializers
627+
)
618628
)
619629
.dependsOn(compiler)
620630

621631
lazy val repl = configureAsSubproject(project)
622632
.settings(disableDocs)
623633
.settings(fatalWarningsSettings)
624634
.settings(publish / skip := true)
625-
.settings(Compile / scalacOptions ++= Seq("-Wconf:cat=deprecation&msg=early initializers:s"))
635+
.settings(Compile / scalacOptions ++= Seq(
636+
"-Wconf:cat=deprecation&msg=early initializers:s",
637+
"-Wconf:cat=scala3-migration&msg=early initializers:s",
638+
))
626639
.dependsOn(compiler, interactive)
627640

628641
lazy val replFrontend = configureAsSubproject(project, srcdir = Some("repl-frontend"))
@@ -651,6 +664,7 @@ lazy val scaladoc = configureAsSubproject(project)
651664
Compile / resourceGenerators += ScaladocSettings.extractResourcesFromWebjar,
652665
Compile / scalacOptions ++= Seq(
653666
"-Wconf:cat=deprecation&msg=early initializers:s",
667+
"-Wconf:cat=scala3-migration&msg=early initializers:s",
654668
),
655669
)
656670
.dependsOn(compiler)
@@ -666,6 +680,7 @@ lazy val sbtBridge = configureAsSubproject(project, srcdir = Some("sbt-bridge"))
666680
libraryDependencies += compilerInterfaceDep % Provided,
667681
Compile / scalacOptions ++= Seq(
668682
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
683+
"-Wconf:cat=scala3-migration&msg=early initializers:s", // compiler heavily relies upon early initializers
669684
),
670685
generateServiceProviderResources("xsbti.compile.CompilerInterface2" -> "scala.tools.xsbt.CompilerBridge"),
671686
generateServiceProviderResources("xsbti.compile.ConsoleInterface1" -> "scala.tools.xsbt.ConsoleBridge"),
@@ -721,6 +736,14 @@ lazy val scalap = configureAsSubproject(project)
721736
xs filter { x => !excluded(x.getName) }
722737
},
723738
Compile / headerResources := Nil,
739+
Compile / scalacOptions ++= Seq(
740+
"-Xsource:2.13",
741+
"-Xsource-features:-case-apply-copy-access,-case-companion-function,-case-copy-by-name",
742+
"-Xsource-features:-implicit-resolution,-infer-override,-any2stringadd,-unicode-escapes-raw",
743+
"-Xsource-features:-string-context-scope,-leading-infix,-package-prefix-implicits,-double-definitions",
744+
//"-Wconf:cat=scala3-migration&msg=inferred type:s",
745+
//"-Wconf:cat=scala3-migration&msg=case companion:s",
746+
),
724747
)
725748
.dependsOn(compiler)
726749

@@ -735,6 +758,7 @@ lazy val partest = configureAsSubproject(project)
735758
libraryDependencies ++= List(testInterfaceDep, diffUtilsDep, junitDep),
736759
Compile / scalacOptions ++= Seq(
737760
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
761+
"-Wconf:cat=scala3-migration&msg=early initializers:s", // compiler heavily relies upon early initializers
738762
),
739763
Compile / javacOptions ++= Seq("-XDenableSunApiLintControl", "-Xlint") ++
740764
(if (fatalWarnings.value) Seq("-Werror") else Seq()),
@@ -807,8 +831,7 @@ lazy val bench = project.in(file("test") / "benchmarks")
807831
if (benchmarkScalaVersion == "") Nil
808832
else "org.scala-lang" % "scala-compiler" % benchmarkScalaVersion :: Nil
809833
},
810-
//scalacOptions ++= Seq("-feature", "-opt:inline:scala/**", "-Wopt"),
811-
scalacOptions ++= Seq("-feature", "-opt:l:inline", "-opt-inline-from:scala/**", "-opt-warnings"),
834+
scalacOptions ++= Seq("-feature", "-opt:inline:scala/**", "-Wopt"),
812835
// Skips JMH source generators during IDE import to avoid needing to compile scala-library during the import
813836
// should not be needed once sbt-jmh 0.4.3 is out (https://github.com/sbt/sbt-jmh/pull/207)
814837
Jmh / bspEnabled := false
@@ -855,6 +878,8 @@ lazy val junit = project.in(file("test") / "junit")
855878
"-Wconf:msg=match may not be exhaustive:s", // if we missed a case, all that happens is the test fails
856879
"-Wconf:cat=lint-nullary-unit&site=.*Test:s", // normal unit test style
857880
"-Ypatmat-exhaust-depth", "40", // despite not caring about patmat exhaustiveness, we still get warnings for this
881+
"-Wconf:cat=deprecation&msg=early initializers:s",
882+
"-Wconf:cat=scala3-migration&msg=early initializers:s",
858883
),
859884
Compile / javacOptions ++= Seq("-Xlint"),
860885
libraryDependencies ++= Seq(junitInterfaceDep, jolDep, diffUtilsDep, compilerInterfaceDep),
@@ -902,6 +927,7 @@ lazy val tasty = project.in(file("test") / "tasty")
902927
},
903928
Compile / scalacOptions ++= Seq(
904929
"-Wconf:cat=lint-nullary-unit&site=.*Test:s", // normal unit test style
930+
raw"-Wconf:cat=optimizer&site=scala\.tools\.nsc\.tasty\.bridge\.TreeOps\.tpd\..*:s", // inline -> outline
905931
),
906932
)
907933

project/ScriptCommands.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ object ScriptCommands {
161161
}
162162

163163
private[this] val enableOptimizer = Seq(
164-
//ThisBuild / Compile / scalacOptions ++= Seq("-opt:inline:scala/**")
165-
ThisBuild / Compile / scalacOptions ++= Seq("-opt:l:inline", "-opt-inline-from:scala/**")
164+
ThisBuild / Compile / scalacOptions ++= Seq("-opt:inline:scala/**")
166165
)
167166

168167
val noDocs = Seq(

src/compiler/scala/tools/nsc/GenericRunnerSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ class GenericRunnerSettings(error: String => Unit, pathFactory: PathFactory) ext
6565
"-nc",
6666
"do not use the legacy fsc compilation daemon").withAbbreviation("-nocompdaemon").withAbbreviation("--no-compilation-daemon")
6767
.withDeprecationMessage("scripts use cold compilation by default; use -Yscriptrunner for custom behavior")
68-
.withPostSetHook { x: BooleanSetting => Yscriptrunner.value = if (x.value) "default" else "resident" }
68+
.withPostSetHook { (x: BooleanSetting) => Yscriptrunner.value = if (x.value) "default" else "resident" }
6969
}

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,8 +1704,9 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
17041704
*/
17051705
@tailrec
17061706
private def resetPackageClass(pclazz: Symbol): Unit = if (typerPhase != NoPhase) {
1707+
val pinfo = enteringPhase(typerPhase)(pclazz.info)
17071708
enteringPhase[Unit](firstPhase) {
1708-
pclazz.setInfo(enteringPhase(typerPhase)(pclazz.info))
1709+
pclazz.setInfo(pinfo)
17091710
}
17101711
if (!pclazz.isRoot) resetPackageClass(pclazz.owner)
17111712
}

src/compiler/scala/tools/nsc/PipelineMain.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
201201
}
202202
strategy match {
203203
case OutlineTypePipeline =>
204-
projects.foreach { p: Task =>
204+
projects.foreach { (p: Task) =>
205205
val depsReady = Future.traverse(dependsOn.getOrElse(p, Nil))(task => p.dependencyReadyFuture(task))
206206
val f = for {
207207
_ <- depsReady

src/compiler/scala/tools/nsc/Reporting.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,15 @@ object Reporting {
832832
if (s == "any") {
833833
Right(Any)
834834
} else if (s.startsWith("msg=")) {
835-
regex(s.substring(4)).map(MessagePattern)
835+
regex(s.substring(4)).map(MessagePattern(_))
836836
} else if (s.startsWith("cat=")) {
837837
val cs = s.substring(4)
838-
val c = WarningCategory.all.get(cs).map(Category)
838+
val c = WarningCategory.all.get(cs).map(Category(_))
839839
c.toRight(s"Unknown category: `$cs`")
840840
} else if (s.startsWith("site=")) {
841-
regex(s.substring(5)).map(SitePattern)
841+
regex(s.substring(5)).map(SitePattern(_))
842842
} else if (s.startsWith("origin=")) {
843-
regex(s.substring(7)).map(DeprecatedOrigin)
843+
regex(s.substring(7)).map(DeprecatedOrigin(_))
844844
} else if (s.startsWith("since")) {
845845
def fail = Left(s"invalid since filter: `$s`; required shape: `since<1.2.3`, `since=3.2`, `since>2`")
846846
if (s.length < 6) fail
@@ -867,7 +867,7 @@ object Reporting {
867867
if (!rootDir.endsWith("/") && !arg.startsWith("/")) pat += '/'
868868
pat ++= arg
869869
if (!arg.endsWith("$")) pat += '$'
870-
regex(pat.toString).map(SourcePattern)
870+
regex(pat.toString).map(SourcePattern(_))
871871
} else {
872872
Left(s"unknown filter: $s")
873873
}

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ trait ParsersCommon extends ScannersCommon {
8585

8686
/** Creates an actual Parens node (only used during parsing.)
8787
*/
88-
@inline final def makeParens(body: => List[Tree]): Parens =
89-
Parens(inParens(if (in.token == RPAREN) Nil else body))
88+
@inline final def makeParens(body: => List[Tree]): Parens = {
89+
val body0 = inParens(if (in.token == RPAREN) Nil else body)
90+
Parens(body0)
91+
}
9092

9193
/** {{{ { `sep` part } }}}. */
9294
def tokenSeparated[T](separator: Token, part: => T): List[T] = {
@@ -544,7 +546,7 @@ self =>
544546
val assumedClosingParens = mutable.Map(RPAREN -> 0, RBRACKET -> 0, RBRACE -> 0)
545547

546548
private var inFunReturnType = false
547-
@inline private def fromWithinReturnType[T](body: => T): T = {
549+
private def fromWithinReturnType[T](body: => T): T = {
548550
val saved = inFunReturnType
549551
inFunReturnType = true
550552
try body
@@ -1877,7 +1879,7 @@ self =>
18771879
def prefixExpr(): Tree =
18781880
if (isUnaryOp) {
18791881
val start = in.offset
1880-
atPos(start) {
1882+
val result =
18811883
if (lookingAhead(isExprIntro)) {
18821884
val namePos = in.offset
18831885
val uname = nme.toUnaryName(rawIdent().toTermName)
@@ -1888,7 +1890,7 @@ self =>
18881890
Select(stripParens(simpleExpr()), uname)
18891891
}
18901892
else simpleExpr()
1891-
}
1893+
atPos(start)(result)
18921894
} else simpleExpr()
18931895

18941896
def xmlLiteral(): Tree
@@ -3237,9 +3239,8 @@ self =>
32373239
migrationWarning(in.offset, "type parameters should not follow newline", since = "2.13.7")
32383240
def orStart(p: Offset) = if (name == tpnme.ERROR) start else p
32393241
val namePos = NamePos(r2p(orStart(nameOffset), orStart(nameOffset)))
3240-
atPos(start, orStart(nameOffset)) {
3241-
savingClassContextBounds {
3242-
val contextBoundBuf = new ListBuffer[Tree]
3242+
def finish = savingClassContextBounds {
3243+
val contextBoundBuf = ListBuffer.empty[Tree]
32433244
val tparams = typeParamClauseOpt(name, contextBoundBuf, ParamOwner.Class)
32443245
classContextBounds = contextBoundBuf.toList
32453246
val tstart = (in.offset :: classContextBounds.map(_.pos.start)).min
@@ -3260,7 +3261,7 @@ self =>
32603261
ensureNonOverlapping(template, tparams)
32613262
result
32623263
}
3263-
}
3264+
atPos(start, orStart(nameOffset))(finish)
32643265
}
32653266

32663267
/** {{{

src/compiler/scala/tools/nsc/ast/parser/Scanners.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ trait Scanners extends ScannersCommon {
12991299
if (token == CHARLIT && !negated) charVal.toLong else intConvert
13001300
}
13011301

1302-
@`inline` def intVal: Long = intVal(negated = false)
1302+
@inline final def intVal: Long = intVal(negated = false)
13031303

13041304
private val zeroFloat = raw"[0.]+(?:[eE][+-]?[0-9]+)?[fFdD]?".r
13051305

@@ -1321,7 +1321,7 @@ trait Scanners extends ScannersCommon {
13211321
}
13221322
}
13231323

1324-
@`inline` def floatVal: Float = floatVal(negated = false)
1324+
@inline final def floatVal: Float = floatVal(negated = false)
13251325

13261326
/** Convert current strVal, base to double value.
13271327
*/
@@ -1341,15 +1341,15 @@ trait Scanners extends ScannersCommon {
13411341
}
13421342
}
13431343

1344-
@`inline` def doubleVal: Double = doubleVal(negated = false)
1344+
@inline final def doubleVal: Double = doubleVal(negated = false)
13451345

1346-
@`inline` def checkNoLetter(): Unit = if (isIdentifierPart(ch) && ch >= ' ') syntaxError("invalid literal number")
1346+
@inline final def checkNoLetter(): Unit = if (isIdentifierPart(ch) && ch >= ' ') syntaxError("invalid literal number")
13471347

1348-
@`inline` private def isNumberSeparator(c: Char): Boolean = c == '_'
1348+
@inline final private def isNumberSeparator(c: Char): Boolean = c == '_'
13491349

1350-
@`inline` private def removeNumberSeparators(s: String): String = if (s.indexOf('_') > 0) s.replace("_", "") else s
1350+
@inline final private def removeNumberSeparators(s: String): String = if (s.indexOf('_') > 0) s.replace("_", "") else s
13511351

1352-
@`inline` private def numberOffset = offset + (if (base == 10) 0 else 2)
1352+
@inline final private def numberOffset = offset + (if (base == 10) 0 else 2)
13531353

13541354
// disallow trailing numeric separator char
13551355
def checkNoTrailingSeparator(): Unit =

src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,24 @@ abstract class ScalaPrimitives {
447447
primitives(s) = code
448448
}
449449

450+
def addPrimitives(cls: Symbol, method: Name, code: Int): Unit =
451+
cls.info.member(method).alternatives match {
452+
case alts if alts.isEmpty => inform(s"Unknown primitive method $cls.$method")
453+
case alts =>
454+
for (alt <- alts) {
455+
val code1 = code match {
456+
case ADD =>
457+
val info = exitingTyper(alt.info)
458+
info.paramTypes match {
459+
case tp :: _ if tp =:= StringTpe => CONCAT
460+
case _ => code
461+
}
462+
case code => code
463+
}
464+
addPrimitive(alt, code1)
465+
}
466+
}
467+
/*
450468
def addPrimitives(cls: Symbol, method: Name, code: Int): Unit = {
451469
val alts = (cls.info member method).alternatives
452470
if (alts.isEmpty)
@@ -461,6 +479,7 @@ abstract class ScalaPrimitives {
461479
)
462480
)
463481
}
482+
*/
464483

465484
def isCoercion(code: Int): Boolean = (code >= B2B) && (code <= D2D)
466485

src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ abstract class BCodeHelpers extends BCodeIdiomatic {
8383
// we prevent this, see `nonAnon` in LambdaLift.
8484
// phase travel necessary: after flatten, the name includes the name of outer classes.
8585
// if some outer name contains $lambda, a non-lambda class is considered lambda.
86-
assert(exitingPickler(!classSym.isDelambdafyFunction), classSym.name)
86+
val ok = exitingPickler(!classSym.isDelambdafyFunction)
87+
assert(ok, classSym.name)
8788
}
8889
r
8990
}

0 commit comments

Comments
 (0)