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

Skip to content

Commit f6c0c59

Browse files
committed
Use -Xsource:3 and accommodate signature moves
1 parent ff5c154 commit f6c0c59

38 files changed

+128
-91
lines changed

build.sbt

Lines changed: 23 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"))
@@ -652,6 +665,7 @@ lazy val scaladoc = configureAsSubproject(project)
652665
Compile / resourceGenerators += ScaladocSettings.extractResourcesFromWebjar,
653666
Compile / scalacOptions ++= Seq(
654667
"-Wconf:cat=deprecation&msg=early initializers:s",
668+
"-Wconf:cat=scala3-migration&msg=early initializers:s",
655669
),
656670
)
657671
.dependsOn(compiler)
@@ -667,6 +681,7 @@ lazy val sbtBridge = configureAsSubproject(project, srcdir = Some("sbt-bridge"))
667681
libraryDependencies += compilerInterfaceDep % Provided,
668682
Compile / scalacOptions ++= Seq(
669683
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
684+
"-Wconf:cat=scala3-migration&msg=early initializers:s", // compiler heavily relies upon early initializers
670685
),
671686
generateServiceProviderResources("xsbti.compile.CompilerInterface2" -> "scala.tools.xsbt.CompilerBridge"),
672687
generateServiceProviderResources("xsbti.compile.ConsoleInterface1" -> "scala.tools.xsbt.ConsoleBridge"),
@@ -736,6 +751,7 @@ lazy val partest = configureAsSubproject(project)
736751
libraryDependencies ++= List(testInterfaceDep, diffUtilsDep, junitDep),
737752
Compile / scalacOptions ++= Seq(
738753
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
754+
"-Wconf:cat=scala3-migration&msg=early initializers:s", // compiler heavily relies upon early initializers
739755
),
740756
Compile / javacOptions ++= Seq("-XDenableSunApiLintControl", "-Xlint") ++
741757
(if (fatalWarnings.value) Seq("-Werror") else Seq()),
@@ -808,8 +824,7 @@ lazy val bench = project.in(file("test") / "benchmarks")
808824
if (benchmarkScalaVersion == "") Nil
809825
else "org.scala-lang" % "scala-compiler" % benchmarkScalaVersion :: Nil
810826
},
811-
//scalacOptions ++= Seq("-feature", "-opt:inline:scala/**", "-Wopt"),
812-
scalacOptions ++= Seq("-feature", "-opt:l:inline", "-opt-inline-from:scala/**", "-opt-warnings"),
827+
scalacOptions ++= Seq("-feature", "-opt:inline:scala/**", "-Wopt"),
813828
// Skips JMH source generators during IDE import to avoid needing to compile scala-library during the import
814829
// should not be needed once sbt-jmh 0.4.3 is out (https://github.com/sbt/sbt-jmh/pull/207)
815830
Jmh / bspEnabled := false
@@ -856,6 +871,8 @@ lazy val junit = project.in(file("test") / "junit")
856871
"-Wconf:msg=match may not be exhaustive:s", // if we missed a case, all that happens is the test fails
857872
"-Wconf:cat=lint-nullary-unit&site=.*Test:s", // normal unit test style
858873
"-Ypatmat-exhaust-depth", "40", // despite not caring about patmat exhaustiveness, we still get warnings for this
874+
"-Wconf:cat=deprecation&msg=early initializers:s",
875+
"-Wconf:cat=scala3-migration&msg=early initializers:s",
859876
),
860877
Compile / javacOptions ++= Seq("-Xlint"),
861878
libraryDependencies ++= Seq(junitInterfaceDep, jolDep, diffUtilsDep, compilerInterfaceDep),

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/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
@@ -825,15 +825,15 @@ object Reporting {
825825
if (s == "any") {
826826
Right(Any)
827827
} else if (s.startsWith("msg=")) {
828-
regex(s.substring(4)).map(MessagePattern)
828+
regex(s.substring(4)).map(MessagePattern(_))
829829
} else if (s.startsWith("cat=")) {
830830
val cs = s.substring(4)
831-
val c = WarningCategory.all.get(cs).map(Category)
831+
val c = WarningCategory.all.get(cs).map(Category(_))
832832
c.toRight(s"Unknown category: `$cs`")
833833
} else if (s.startsWith("site=")) {
834-
regex(s.substring(5)).map(SitePattern)
834+
regex(s.substring(5)).map(SitePattern(_))
835835
} else if (s.startsWith("origin=")) {
836-
regex(s.substring(7)).map(DeprecatedOrigin)
836+
regex(s.substring(7)).map(DeprecatedOrigin(_))
837837
} else if (s.startsWith("since")) {
838838
def fail = Left(s"invalid since filter: `$s`; required shape: `since<1.2.3`, `since=3.2`, `since>2`")
839839
if (s.length < 6) fail
@@ -860,7 +860,7 @@ object Reporting {
860860
if (!rootDir.endsWith("/") && !arg.startsWith("/")) pat += '/'
861861
pat ++= arg
862862
if (!arg.endsWith("$")) pat += '$'
863-
regex(pat.toString).map(SourcePattern)
863+
regex(pat.toString).map(SourcePattern(_))
864864
} else {
865865
Left(s"unknown filter: $s")
866866
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class BTypesFromSymbols[G <: Global](val global: G) extends BTypes {
3333
import codeGen.CodeGenImpl._
3434
import postProcessor.{bTypesFromClassfile, byteCodeRepository}
3535

36-
val coreBTypes = new CoreBTypesFromSymbols[G] {
36+
val coreBTypes: CoreBTypesFromSymbols[G] { val bTypes: BTypesFromSymbols.this.type} = new CoreBTypesFromSymbols[G] {
3737
val bTypes: BTypesFromSymbols.this.type = BTypesFromSymbols.this
3838
}
3939
import coreBTypes._

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ abstract class ClassfileWriters {
8282
if (distinctOutputs.size == 1) new SingleClassWriter(FileWriter(global, distinctOutputs.head, jarManifestMainClass))
8383
else {
8484
val sourceToOutput: Map[AbstractFile, AbstractFile] = global.currentRun.units.map(unit => (unit.source.file, frontendAccess.compilerSettings.outputDirectory(unit.source.file))).toMap
85-
new MultiClassWriter(sourceToOutput, distinctOutputs.iterator.map { output: AbstractFile => output -> FileWriter(global, output, jarManifestMainClass) }.toMap)
85+
new MultiClassWriter(sourceToOutput, distinctOutputs.iterator.map { (output: AbstractFile) => output -> FileWriter(global, output, jarManifestMainClass) }.toMap)
8686
}
8787
}
8888

src/compiler/scala/tools/nsc/classpath/DirectoryClassPath.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
329329
}
330330

331331
case class DirectoryClassPath(dir: File) extends JFileDirectoryLookup[ClassFileEntryImpl] with NoSourcePaths {
332-
override def findClass(className: String): Option[ClassRepresentation] = findClassFile(className) map ClassFileEntryImpl
332+
override def findClass(className: String): Option[ClassRepresentation] = findClassFile(className).map(ClassFileEntryImpl(_))
333333

334334
def findClassFile(className: String): Option[AbstractFile] = {
335335
val relativePath = FileUtils.dirPath(className)
@@ -354,7 +354,7 @@ case class DirectorySourcePath(dir: File) extends JFileDirectoryLookup[SourceFil
354354
protected def createFileEntry(file: AbstractFile): SourceFileEntryImpl = SourceFileEntryImpl(file)
355355
protected def isMatchingFile(f: File, siblingExists: String => Boolean): Boolean = endsScalaOrJava(f.getName)
356356

357-
override def findClass(className: String): Option[ClassRepresentation] = findSourceFile(className) map SourceFileEntryImpl
357+
override def findClass(className: String): Option[ClassRepresentation] = findSourceFile(className).map(SourceFileEntryImpl(_))
358358

359359
private def findSourceFile(className: String): Option[AbstractFile] = {
360360
val relativePath = FileUtils.dirPath(className)

src/compiler/scala/tools/nsc/classpath/VirtualDirectoryClassPath.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ case class VirtualDirectoryClassPath(dir: VirtualDirectory) extends ClassPath wi
3939
// mimic the behavior of the old nsc.util.DirectoryClassPath
4040
def asURLs: Seq[URL] = Seq(new URI("file://_VIRTUAL_/" + dir.name).toURL)
4141
def asClassPathStrings: Seq[String] = Seq(dir.path)
42-
override def findClass(className: String): Option[ClassRepresentation] = findClassFile(className) map ClassFileEntryImpl
42+
override def findClass(className: String): Option[ClassRepresentation] = findClassFile(className).map(ClassFileEntryImpl(_))
4343

4444
def findClassFile(className: String): Option[AbstractFile] = {
4545
val relativePath = FileUtils.dirPath(className) + ".class"

src/compiler/scala/tools/nsc/tasty/bridge/TreeOps.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
* additional information regarding copyright ownership.
1111
*/
1212

13-
package scala.tools.nsc.tasty.bridge
13+
package scala.tools.nsc.tasty
14+
package bridge
1415

15-
import scala.tools.nsc.tasty.{TastyUniverse, TastyModes}, TastyModes._
16+
import TastyModes._
1617

1718
import scala.tools.tasty.TastyName
1819
import scala.reflect.internal.Flags

0 commit comments

Comments
 (0)