Skip to content

Commit dcf7bd0

Browse files
authored
Merge pull request #14 from scala/2.13.x
2.13.x
2 parents 3637705 + ecb1c78 commit dcf7bd0

File tree

186 files changed

+4247
-4112
lines changed

Some content is hidden

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

186 files changed

+4247
-4112
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ If you need some help with your PR at any time, please feel free to @-mention an
3939

4040
P.S.: If you have some spare time to help out around here, we would be delighted to add your name to this list!
4141

42+
4243
# Repository structure
4344

4445
```
@@ -73,6 +74,13 @@ You need the following tools:
7374
Mac OS X and Linux work. Windows may work if you use Cygwin. Community help with keeping
7475
the build working on Windows is appreciated.
7576

77+
## Tools we use
78+
79+
We are grateful for the following OSS licenses:
80+
- [JProfiler Java profiler](https://www.ej-technologies.com/products/jprofiler/overview.html)
81+
- [YourKit Java Profiler](https://www.yourkit.com/java/profiler/)
82+
- [IntelliJ IDEA](https://www.jetbrains.com/idea/download/)
83+
7684
## Build setup
7785

7886
### Basics

build.sbt

+16-54
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ lazy val compiler = configureAsSubproject(project)
394394
description := "Scala Compiler",
395395
libraryDependencies ++= Seq(antDep, asmDep),
396396
// These are only needed for the POM:
397-
libraryDependencies ++= Seq(scalaXmlDep, jlineDep % "optional"),
397+
// TODO: jline dependency is only needed for the REPL shell, which should move to its own jar
398+
libraryDependencies ++= Seq(scalaXmlDep, jlineDep),
398399
buildCharacterPropertiesFile := (resourceManaged in Compile).value / "scala-buildcharacter.properties",
399400
resourceGenerators in Compile += generateBuildCharacterPropertiesFile.map(file => Seq(file)).taskValue,
400401
// this a way to make sure that classes from interactive and scaladoc projects
@@ -406,8 +407,7 @@ lazy val compiler = configureAsSubproject(project)
406407
(products in Compile in packageBin in LocalProject("interactive")).value ++
407408
(products in Compile in packageBin in LocalProject("scaladoc")).value ++
408409
(products in Compile in packageBin in LocalProject("repl")).value ++
409-
(products in Compile in packageBin in LocalProject("repl-jline")).value ++
410-
(products in Compile in packageBin in LocalProject("repl-jline-embedded")).value,
410+
(products in Compile in packageBin in LocalProject("repl-frontend")).value,
411411
includeFilter in unmanagedResources in Compile :=
412412
"*.tmpl" | "*.xml" | "*.js" | "*.css" | "*.html" | "*.properties" | "*.swf" |
413413
"*.png" | "*.gif" | "*.gif" | "*.txt",
@@ -466,58 +466,21 @@ lazy val interactive = configureAsSubproject(project)
466466
lazy val repl = configureAsSubproject(project)
467467
.settings(disableDocs)
468468
.settings(disablePublishing)
469-
.settings(
470-
connectInput in run := true,
471-
run := (run in Compile).partialInput(" -usejavacp").evaluated // Automatically add this so that `repl/run` works without additional arguments.
472-
)
473469
.dependsOn(compiler, interactive)
474470

475-
lazy val replJline = configureAsSubproject(Project("repl-jline", file(".") / "src" / "repl-jline"))
471+
lazy val replFrontend = configureAsSubproject(Project("repl-frontend", file(".") / "src" / "repl-frontend"))
476472
.settings(disableDocs)
477473
.settings(disablePublishing)
478474
.settings(
479475
libraryDependencies += jlineDep,
480-
name := "scala-repl-jline"
476+
name := "scala-repl-frontend"
481477
)
482-
.dependsOn(repl)
483-
484-
lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target" / "repl-jline-embedded-src-dummy")
485-
.settings(scalaSubprojectSettings)
486-
.settings(disablePublishing)
487478
.settings(
488-
name := "scala-repl-jline-embedded",
489-
// There is nothing to compile for this project. Instead we use the compile task to create
490-
// shaded versions of repl-jline and jline.jar. dist/mkBin puts all of quick/repl,
491-
// quick/repl-jline and quick/repl-jline-shaded on the classpath for quick/bin scripts.
492-
// This is different from the Ant build where all parts are combined into quick/repl, but
493-
// it is cleaner because it avoids circular dependencies.
494-
compile in Compile := (compile in Compile).dependsOn(Def.task {
495-
import java.util.jar._
496-
import collection.JavaConverters._
497-
val inputs: Iterator[JarJar.Entry] = {
498-
val repljlineClasses = (products in Compile in replJline).value.flatMap(base => Path.allSubpaths(base).map(x => (base, x._1)))
499-
val jlineJAR = findJar((dependencyClasspath in Compile).value, jlineDep).get.data
500-
val jarFile = new JarFile(jlineJAR)
501-
val jarEntries = jarFile.entries.asScala.filterNot(_.isDirectory).map(entry => JarJar.JarEntryInput(jarFile, entry))
502-
def compiledClasses = repljlineClasses.iterator.map { case (base, file) => JarJar.FileInput(base, file) }
503-
(jarEntries ++ compiledClasses).filter(x =>
504-
x.name.endsWith(".class") || x.name.endsWith(".properties") || x.name.startsWith("META-INF/native") || x.name.startsWith("META-INF/maven")
505-
)
506-
}
507-
import JarJar.JarJarConfig._
508-
val config: Seq[JarJar.JarJarConfig] = Seq(
509-
Rule("org.fusesource.**", "scala.tools.fusesource_embedded.@1"),
510-
Rule("jline.**", "scala.tools.jline_embedded.@1"),
511-
Rule("scala.tools.nsc.interpreter.jline.**", "scala.tools.nsc.interpreter.jline_embedded.@1"),
512-
Keep("scala.tools.**")
513-
)
514-
val outdir = (classDirectory in Compile).value
515-
JarJar(inputs, outdir, config)
516-
}).value,
517-
connectInput in run := true
518-
479+
connectInput in run := true,
480+
run := (run in Compile).partialInput(" -usejavacp").evaluated // Automatically add this so that `repl/run` works without additional arguments.
519481
)
520-
.dependsOn(replJline)
482+
.dependsOn(repl)
483+
521484

522485
lazy val scaladoc = configureAsSubproject(project)
523486
.settings(disableDocs)
@@ -544,7 +507,7 @@ lazy val scalap = configureAsSubproject(project)
544507
.dependsOn(compiler)
545508

546509
lazy val partestExtras = Project("partest-extras", file(".") / "src" / "partest-extras")
547-
.dependsOn(replJlineEmbedded, scaladoc)
510+
.dependsOn(replFrontend, scaladoc)
548511
.settings(commonSettings)
549512
.settings(generatePropertiesFileSettings)
550513
.settings(clearSourceAndResourceDirectories)
@@ -654,7 +617,7 @@ lazy val partestJavaAgent = Project("partest-javaagent", file(".") / "src" / "pa
654617
)
655618

656619
lazy val test = project
657-
.dependsOn(compiler, interactive, replJlineEmbedded, scalap, partestExtras, partestJavaAgent, scaladoc)
620+
.dependsOn(compiler, interactive, replFrontend, scalap, partestExtras, partestJavaAgent, scaladoc)
658621
.configs(IntegrationTest)
659622
.settings(commonSettings)
660623
.settings(disableDocs)
@@ -867,15 +830,15 @@ lazy val root: Project = (project in file("."))
867830
antStyle := false,
868831
incOptions := incOptions.value.withNameHashing(!antStyle.value).withAntStyle(antStyle.value)
869832
)
870-
.aggregate(library, reflect, compiler, interactive, repl, replJline, replJlineEmbedded,
833+
.aggregate(library, reflect, compiler, interactive, repl, replFrontend,
871834
scaladoc, scalap, partestExtras, junit, scalaDist).settings(
872835
sources in Compile := Seq.empty,
873836
onLoadMessage := """|*** Welcome to the sbt build definition for Scala! ***
874837
|Check README.md for more information.""".stripMargin
875838
)
876839

877840
// The following subprojects' binaries are required for building "pack":
878-
lazy val distDependencies = Seq(replJline, replJlineEmbedded, compiler, library, reflect, scalap, scaladoc)
841+
lazy val distDependencies = Seq(replFrontend, compiler, library, reflect, scalap, scaladoc)
879842

880843
lazy val dist = (project in file("dist"))
881844
.settings(commonSettings)
@@ -978,7 +941,7 @@ lazy val mkBinImpl: Def.Initialize[Task[Seq[File]]] = Def.task {
978941

979942
streams.value.log.info(s"Creating scripts in $quickOutDir and $packOutDir")
980943

981-
mkBin("scala" , "scala.tools.nsc.MainGenericRunner", (fullClasspath in Compile in replJlineEmbedded).value) ++
944+
mkBin("scala" , "scala.tools.nsc.MainGenericRunner", (fullClasspath in Compile in replFrontend).value) ++
982945
mkBin("scalac" , "scala.tools.nsc.Main", (fullClasspath in Compile in compiler).value) ++
983946
mkBin("fsc" , "scala.tools.nsc.CompileClient", (fullClasspath in Compile in compiler).value) ++
984947
mkBin("scaladoc" , "scala.tools.nsc.ScalaDoc", (fullClasspath in Compile in scaladoc).value) ++
@@ -1009,7 +972,7 @@ watchSources ++= PartestUtil.testFilePaths((baseDirectory in ThisBuild).value, (
1009972
commands ++= {
1010973
val commands =
1011974
List(("scalac", "compiler", "scala.tools.nsc.Main"),
1012-
("scala", "repl-jline-embedded", "scala.tools.nsc.MainGenericRunner"),
975+
("scala", "repl-frontend", "scala.tools.nsc.MainGenericRunner"),
1013976
("scaladoc", "scaladoc", "scala.tools.nsc.ScalaDoc"))
1014977

1015978
commands.map {
@@ -1051,8 +1014,7 @@ intellij := {
10511014
moduleDeps(partestJavaAgent).value,
10521015
moduleDeps(reflect).value,
10531016
moduleDeps(repl).value,
1054-
moduleDeps(replJline).value,
1055-
// moduleDeps(replJlineEmbedded).value, // No sources
1017+
moduleDeps(replFrontend).value,
10561018
// moduleDeps(root).value, // No sources
10571019
// moduleDeps(scalaDist).value, // No sources
10581020
moduleDeps(scalacheck, config = Test).value,

project/ScalaOptionParser.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ object ScalaOptionParser {
2525
def ChoiceSetting(name: String, choices: List[String]): Parser[String] =
2626
concat(token(concat(name ~ ":")) ~ token(StringBasic.examples(choices: _*)).map(_.mkString))
2727
def MultiChoiceSetting(name: String, choices: List[String]): Parser[String] =
28-
concat(token(concat(name ~ ":")) ~ rep1sep(token(StringBasic.examples(choices: _*)), token(",")).map(_.mkString))
28+
concat(token(concat(name ~ ":")) ~ rep1sep(token(StringBasic.examples(choices: _*)), token(",")).map(_.mkString(",")))
2929
def PathSetting(name: String): Parser[String] = {
30-
concat(concat(token(name) ~ Space.string) ~ rep1sep(JarOrDirectoryParser.filter(!_.contains(":"), x => x), token(java.io.File.pathSeparator)).map(_.mkString))
30+
concat(concat(token(name) ~ Space.string) ~ rep1sep(JarOrDirectoryParser.filter(!_.contains(":"), x => x), token(java.io.File.pathSeparator)).map(_.mkString(java.io.File.pathSeparator)))
3131
}
3232
def FileSetting(name: String): Parser[String] = {
33-
concat(concat(token(name) ~ Space.string) ~ rep1sep(JarOrDirectoryParser.filter(!_.contains(":"), x => x), token(java.io.File.pathSeparator)).map(_.mkString))
33+
concat(concat(token(name) ~ Space.string) ~ rep1sep(JarOrDirectoryParser.filter(!_.contains(":"), x => x), token(java.io.File.pathSeparator)).map(_.mkString(java.io.File.pathSeparator)))
3434
}
3535
val Phase = token(NotSpace.examples(phases: _*))
3636
def PhaseSettingParser(name: String): Parser[String] = {

project/VersionUtil.scala

+39-26
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import BuildSettings.autoImport._
1212
object VersionUtil {
1313
lazy val copyrightString = settingKey[String]("Copyright string.")
1414
lazy val versionProperties = settingKey[Versions]("Version properties.")
15+
lazy val gitProperties = settingKey[GitProperties]("Current git information")
1516
lazy val buildCharacterPropertiesFile = settingKey[File]("The file which gets generated by generateBuildCharacterPropertiesFile")
1617
lazy val generateVersionPropertiesFile = taskKey[File]("Generate version properties file.")
1718
lazy val generateBuildCharacterPropertiesFile = taskKey[File]("Generate buildcharacter.properties file.")
@@ -20,6 +21,7 @@ object VersionUtil {
2021
lazy val globalVersionSettings = Seq[Setting[_]](
2122
// Set the version properties globally (they are the same for all projects)
2223
versionProperties in Global := versionPropertiesImpl.value,
24+
gitProperties := gitPropertiesImpl.value,
2325
version in Global := versionProperties.value.mavenVersion
2426
)
2527

@@ -50,6 +52,39 @@ object VersionUtil {
5052
)
5153
}
5254

55+
case class GitProperties(date: String, sha: String)
56+
57+
private lazy val gitPropertiesImpl: Def.Initialize[GitProperties] = Def.setting {
58+
val log = sLog.value
59+
val (dateObj, sha) = {
60+
try {
61+
// Use JGit to get the commit date and SHA
62+
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
63+
import org.eclipse.jgit.revwalk.RevWalk
64+
val db = new FileRepositoryBuilder().findGitDir.build
65+
val head = db.resolve("HEAD")
66+
if (head eq null) {
67+
log.info("No git HEAD commit found -- Using current date and 'unknown' SHA")
68+
(new Date, "unknown")
69+
} else {
70+
val commit = new RevWalk(db).parseCommit(head)
71+
(new Date(commit.getCommitTime.toLong * 1000L), commit.getName.substring(0, 7))
72+
}
73+
} catch {
74+
case ex: Exception =>
75+
log.error("Could not determine commit date + SHA: " + ex)
76+
log.trace(ex)
77+
(new Date, "unknown")
78+
}
79+
}
80+
val date = {
81+
val df = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.ENGLISH)
82+
df.setTimeZone(TimeZone.getTimeZone("UTC"))
83+
df.format(dateObj)
84+
}
85+
GitProperties(date, sha)
86+
}
87+
5388
/** Compute the canonical, Maven and OSGi version number from `baseVersion` and `baseVersionSuffix`.
5489
* Examples of the generated versions:
5590
*
@@ -68,6 +103,7 @@ object VersionUtil {
68103
* value "SPLIT" is used to split the real suffix off from `baseVersion` instead and then apply the usual logic. */
69104
private lazy val versionPropertiesImpl: Def.Initialize[Versions] = Def.setting {
70105
val log = sLog.value
106+
val (date, sha) = (gitProperties.value.date, gitProperties.value.sha)
71107

72108
val (base, suffix) = {
73109
val (b, s) = (baseVersion.value, baseVersionSuffix.value)
@@ -78,31 +114,7 @@ object VersionUtil {
78114
} else (b, s)
79115
}
80116

81-
val (dateObj, sha) = {
82-
try {
83-
// Use JGit to get the commit date and SHA
84-
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
85-
import org.eclipse.jgit.revwalk.RevWalk
86-
val db = new FileRepositoryBuilder().findGitDir.build
87-
val head = db.resolve("HEAD")
88-
if(head eq null) {
89-
log.info("No git HEAD commit found -- Using current date and 'unknown' SHA")
90-
(new Date, "unknown")
91-
} else {
92-
val commit = new RevWalk(db).parseCommit(head)
93-
(new Date(commit.getCommitTime.toLong * 1000L), commit.getName.substring(0, 7))
94-
}
95-
} catch { case ex: Exception =>
96-
log.error("Could not determine commit date + SHA: "+ex)
97-
log.trace(ex)
98-
(new Date, "unknown")
99-
}
100-
}
101-
val date = {
102-
val df = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.ENGLISH)
103-
df.setTimeZone(TimeZone.getTimeZone("UTC"))
104-
df.format(dateObj)
105-
}
117+
106118

107119
val Patch = """\d+\.\d+\.(\d+)""".r
108120
def cross = base match {
@@ -115,9 +127,10 @@ object VersionUtil {
115127
case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-$sha-SNAPSHOT", s"$base.v$date-$sha", false)
116128
case "SHA" => (s"$base-$sha", s"-$cross-$sha", s"$base.v$date-$sha", false)
117129
case "" => (s"$base", "", s"$base.v$date-VFINAL-$sha", true)
118-
case suffix => (s"$base-$suffix", s"-$suffix", s"$base.v$date-$suffix-$sha", true)
130+
case _ => (s"$base-$suffix", s"-$suffix", s"$base.v$date-$suffix-$sha", true)
119131
}
120132

133+
121134
Versions(canonicalV, base, mavenSuffix, osgiV, sha, date, release)
122135
}
123136

spec/01-lexical-syntax.md

+14
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,20 @@ but are required to be properly nested. Therefore, a comment like
553553
`/* /* */` will be rejected as having an unterminated
554554
comment.
555555
556+
## Trailing Commas in Multi-line Expressions
557+
558+
If a comma (`,`) is followed immediately, ignoring whitespace, by a newline and
559+
a closing parenthesis (`)`), bracket (`]`), or brace (`}`), then the comma is
560+
treated as a "trailing comma" and is ignored. For example:
561+
562+
```scala
563+
foo(
564+
23,
565+
"bar",
566+
true,
567+
)
568+
```
569+
556570
## XML mode
557571
558572
In order to allow literal inclusion of XML fragments, lexical analysis

spec/02-identifiers-names-and-scopes.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,24 @@ precedences between them.
105105
package p { // `X' bound by package clause
106106
import Console._ // `println' bound by wildcard import
107107
object Y {
108-
println(s"L4: $X") // `X' refers to `p.X' here
108+
println(s"L4: \$X") // `X' refers to `p.X' here
109109
locally {
110110
import q._ // `X' bound by wildcard import
111-
println(s"L7: $X") // `X' refers to `q.X' here
111+
println(s"L7: \$X") // `X' refers to `q.X' here
112112
import X._ // `x' and `y' bound by wildcard import
113-
println(s"L9: $x") // `x' refers to `q.X.x' here
113+
println(s"L9: \$x") // `x' refers to `q.X.x' here
114114
locally {
115115
val x = 3 // `x' bound by local definition
116-
println(s"L12: $x") // `x' refers to constant `3' here
116+
println(s"L12: \$x") // `x' refers to constant `3' here
117117
locally {
118118
import q.X._ // `x' and `y' bound by wildcard import
119-
// println(s"L15: $x") // reference to `x' is ambiguous here
119+
// println(s"L15: \$x") // reference to `x' is ambiguous here
120120
import X.y // `y' bound by explicit import
121-
println(s"L17: $y") // `y' refers to `q.X.y' here
121+
println(s"L17: \$y") // `y' refers to `q.X.y' here
122122
locally {
123123
val x = "abc" // `x' bound by local definition
124124
import p.X._ // `x' and `y' bound by wildcard import
125-
// println(s"L21: $y") // reference to `y' is ambiguous here
126-
println(s"L22: $x") // `x' refers to string "abc" here
125+
// println(s"L21: \$y") // reference to `y' is ambiguous here
126+
println(s"L22: \$x") // `x' refers to string "abc" here
127127
}}}}}}
128128
```

src/compiler/scala/reflect/reify/phases/Metalevels.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package scala.reflect.reify
22
package phases
33

4-
import scala.collection.{ mutable }
4+
import scala.collection.mutable
55

66
trait Metalevels {
77
self: Reifier =>

src/compiler/scala/tools/cmd/CommandLine.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CommandLine(val spec: Reference, val originalArgs: List[String]) extends C
2727
def mapForUnary(opt: String) = Map(fromOpt(opt) -> ValueForUnaryOption)
2828
def errorFn(msg: String) = println(msg)
2929

30-
/** argMap is option -> argument (or "" if it is a unary argument)
30+
/** argMap is option -> argument (or "true" if it is a unary argument)
3131
* residualArgs are what is left after removing the options and their args.
3232
*/
3333
lazy val (argMap, residualArgs): (Map[String, String], List[String]) = {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
580580
val runsRightAfter = None
581581
} with Delambdafy
582582

583-
// phaseName = "bcode"
583+
// phaseName = "jvm"
584584
object genBCode extends {
585585
val global: Global.this.type = Global.this
586586
val runsAfter = List("cleanup")
@@ -1404,11 +1404,11 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14041404

14051405
units match {
14061406
case Nil => checkDeprecations() // nothing to compile, report deprecated options
1407-
case _ => compileUnits(units, firstPhase)
1407+
case _ => compileUnits(units)
14081408
}
14091409
}
14101410

1411-
def compileUnits(units: List[CompilationUnit], fromPhase: Phase): Unit =
1411+
def compileUnits(units: List[CompilationUnit], fromPhase: Phase = firstPhase): Unit =
14121412
compileUnitsInternal(units, fromPhase)
14131413

14141414
private def compileUnitsInternal(units: List[CompilationUnit], fromPhase: Phase) {

0 commit comments

Comments
 (0)