Skip to content

Commit e253ad1

Browse files
authored
Merge branch '2.13.x' into inPartest
2 parents 71007d1 + c4adc81 commit e253ad1

File tree

147 files changed

+4057
-898
lines changed

Some content is hidden

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

147 files changed

+4057
-898
lines changed

CODE_OF_CONDUCT.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
all repositories in the [scala](https://github.com/scala) and [scalacenter](https://github.com/scalacenter) organizations are covered by the Scala Code of Conduct: https://scala-lang.org/conduct/

build.sbt

+52-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
* - to modularize the Scala compiler or library further
3333
*/
3434

35-
import java.io.{PrintWriter, StringWriter}
36-
3735
import sbt.TestResult
3836
import sbt.testing.TestSelector
3937

4038
import scala.build._
4139
import VersionUtil._
40+
import scala.tools.nsc.util.ScalaClassLoader.URLClassLoader
4241

4342
// Non-Scala dependencies:
4443
val junitDep = "junit" % "junit" % "4.11"
@@ -117,6 +116,34 @@ lazy val instanceSettings = Seq[Setting[_]](
117116
Quiet.silenceScalaBinaryVersionWarning
118117
)
119118

119+
// be careful with using this instance, as it may cause performance problems (e.g., MetaSpace exhaustion)r
120+
lazy val quickInstanceSettings = Seq[Setting[_]](
121+
organization := "org.scala-lang",
122+
// we don't cross build Scala itself
123+
crossPaths := false,
124+
// do not add Scala library jar as a dependency automatically
125+
autoScalaLibrary := false,
126+
// Avoid circular dependencies for scalaInstance (see https://github.com/sbt/sbt/issues/1872)
127+
managedScalaInstance := false,
128+
scalaInstance := {
129+
// TODO: express in terms of distDependencies?
130+
val cpElems: Seq[java.io.File] = (fullClasspath in Compile in replFrontend).value.map(_.data) ++ (fullClasspath in Compile in scaladoc).value.map(_.data)
131+
val libraryJar = cpElems.find(_.getPath.endsWith("classes/library")).get
132+
val compilerJar = cpElems.find(_.getPath.endsWith("classes/compiler")).get
133+
val extraJars = cpElems.filter(f => (f ne libraryJar) && (f ne compilerJar))
134+
val v = (version in Global).value
135+
new ScalaInstance(v, new URLClassLoader(cpElems.map(_.toURI.toURL).toArray[URL], null), libraryJar, compilerJar, extraJars, Some(v))
136+
},
137+
// As of sbt 0.13.12 (sbt/sbt#2634) sbt endeavours to align both scalaOrganization and scalaVersion
138+
// in the Scala artefacts, for example scala-library and scala-compiler.
139+
// This doesn't work in the scala/scala build because the version of scala-library and the scalaVersion of
140+
// scala-library are correct to be different. So disable overriding.
141+
ivyScala ~= (_ map (_ copy (overrideScalaVersion = false))),
142+
Quiet.silenceScalaBinaryVersionWarning
143+
)
144+
145+
146+
120147
lazy val commonSettings = instanceSettings ++ clearSourceAndResourceDirectories ++ publishSettings ++ Seq[Setting[_]](
121148
// we always assume that Java classes are standalone and do not have any dependency
122149
// on Scala classes
@@ -561,6 +588,27 @@ lazy val junit = project.in(file("test") / "junit")
561588
unmanagedSourceDirectories in Test := List(baseDirectory.value)
562589
)
563590

591+
// imported from scalamacros/paradise for the test suite -- TODO: integrate into build structure, get rid of quickInstanceSettings?
592+
lazy val macroAnnot = project.in(file("test") / "macro-annot")
593+
.dependsOn(library, reflect, compiler, repl, replFrontend, scaladoc)
594+
.settings(disableDocs)
595+
.settings(disablePublishing)
596+
.settings(quickInstanceSettings) // use quick compiler as Scala Instance
597+
.settings(
598+
fork in Test := true,
599+
javaOptions in Test += "-Xss1M",
600+
libraryDependencies ++= Seq(junitDep, junitInterfaceDep),
601+
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v",
602+
s"-Dsbt.paths.tests.classpath=${(fullClasspath in Test).value.files.map(_.getAbsolutePath).mkString(java.io.File.pathSeparatorChar.toString)}"),
603+
604+
baseDirectory in Compile := (baseDirectory in ThisBuild).value,
605+
baseDirectory in Test := (baseDirectory in ThisBuild).value,
606+
607+
scalacOptions += "-Ymacro-annotations",
608+
scalacOptions += "-Ywarn-unused-import",
609+
scalacOptions += "-Xfatal-warnings"
610+
)
611+
564612
lazy val scalacheck = project.in(file("test") / "scalacheck")
565613
.dependsOn(library, reflect, compiler, scaladoc)
566614
.settings(clearSourceAndResourceDirectories)
@@ -805,6 +853,7 @@ lazy val root: Project = (project in file("."))
805853
val results = ScriptCommands.sequence[(Result[Unit], String)](List(
806854
(Keys.test in Test in junit).result map (_ -> "junit/test"),
807855
(Keys.test in Test in scalacheck).result map (_ -> "scalacheck/test"),
856+
(Keys.test in Test in macroAnnot).result map (_ -> "macroAnnot/test"),
808857
(testOnly in IntegrationTest in testP).toTask(" -- run").result map (_ -> "partest run"),
809858
(testOnly in IntegrationTest in testP).toTask(" -- pos neg jvm").result map (_ -> "partest pos neg jvm"),
810859
(testOnly in IntegrationTest in testP).toTask(" -- res scalap specialized").result map (_ -> "partest res scalap specialized"),
@@ -872,7 +921,7 @@ lazy val root: Project = (project in file("."))
872921
}
873922
)
874923
.aggregate(library, reflect, compiler, interactive, repl, replFrontend,
875-
scaladoc, scalap, partest, junit, scalaDist).settings(
924+
scaladoc, scalap, partest, junit, scalaDist, macroAnnot).settings(
876925
sources in Compile := Seq.empty,
877926
onLoadMessage := """|*** Welcome to the sbt build definition for Scala! ***
878927
|Check README.md for more information.""".stripMargin

doc/LICENSE.md

-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,4 @@ This license is used by the following third-party libraries:
5656
This license is used by the following third-party libraries:
5757

5858
* jquery
59-
* sizzle
6059
* tools tooltip

doc/License.rtf

-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,4 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \'93AS IS\'9
5353

5454
\fs26 This license is used by the following third-party libraries:\
5555
\'95 jquery\
56-
\'95 sizzle\
5756
\'95 tools tooltip\

doc/licenses/mit_sizzle.txt

-13
This file was deleted.

project/ScalaOptionParser.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ object ScalaOptionParser {
8787
"-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug",
8888
"-Yide-debug", "-Yinfer-argument-types",
8989
"-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",
90-
"-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-predef",
90+
"-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-predef", "-Ymacro-annotations",
9191
"-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypos-debug", "-Ypresentation-debug",
9292
"-Ypresentation-strict", "-Ypresentation-verbose", "-Yquasiquote-debug", "-Yrangepos", "-Yreify-copypaste", "-Yreify-debug", "-Yrepl-class-based",
9393
"-Yrepl-sync", "-Yshow-member-pos", "-Yshow-symkinds", "-Yshow-symowners", "-Yshow-syms", "-Yshow-trees", "-Yshow-trees-compact", "-Yshow-trees-stringified", "-Ytyper-debug",

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
445445
// I only changed analyzer.
446446
//
447447
// factory for phases: namer, packageobjects, typer
448-
lazy val analyzer = new {
449-
val global: Global.this.type = Global.this
450-
} with Analyzer
448+
lazy val analyzer =
449+
if (settings.YmacroAnnotations) new { val global: Global.this.type = Global.this } with Analyzer with MacroAnnotationNamers
450+
else new { val global: Global.this.type = Global.this } with Analyzer
451451

452452
// phaseName = "patmat"
453453
object patmat extends {

src/compiler/scala/tools/nsc/ast/TreeInfo.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
package scala.tools.nsc
77
package ast
88

9+
import scala.reflect.internal.MacroAnnotionTreeInfo
10+
911
/** This class ...
1012
*
1113
* @author Martin Odersky
1214
* @version 1.0
1315
*/
14-
abstract class TreeInfo extends scala.reflect.internal.TreeInfo {
16+
abstract class TreeInfo extends scala.reflect.internal.TreeInfo with MacroAnnotionTreeInfo {
1517
val global: Global
1618
import global._
1719
import definitions._

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -2370,10 +2370,7 @@ self =>
23702370
val nameOffset = in.offset
23712371
val name = ident()
23722372
var bynamemod = 0
2373-
val tpt =
2374-
if ((settings.YmethodInfer && !owner.isTypeName) && in.token != COLON) {
2375-
TypeTree()
2376-
} else { // XX-METHOD-INFER
2373+
val tpt = {
23772374
accept(COLON)
23782375
if (in.token == ARROW) {
23792376
if (owner.isTypeName && !mods.isLocalToThis)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ trait Scanners extends ScannersCommon {
212212

213213
/** Clear buffer and set name and token */
214214
private def finishNamed(idtoken: Token = IDENTIFIER): Unit = {
215-
name = newTermName(cbuf.toString)
215+
name = newTermName(cbuf.toArray)
216216
cbuf.clear()
217217
token = idtoken
218218
if (idtoken == IDENTIFIER) {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -682,8 +682,9 @@ abstract class BTypesFromSymbols[G <: Global](val global: G) extends BTypes {
682682
// Note that the presence of the `FINAL` flag on a symbol does not correspond 1:1 to emitting
683683
// ACC_FINAL in bytecode.
684684
//
685-
// Top-level modules are marked ACC_FINAL in bytecode (even without the FINAL flag). Nested
686-
// objects don't get the flag to allow overriding (under -Yoverride-objects, scala/bug#5676).
685+
// Top-level modules are marked ACC_FINAL in bytecode (even without the FINAL flag).
686+
// Currently, nested objects don't get the flag (originally, to allow overriding under the now-removed -Yoverride-objects, scala/bug#5676).
687+
// TODO: give nested objects the ACC_FINAL flag again, since we won't let them be overridden
687688
//
688689
// For fields, only eager val fields can receive ACC_FINAL. vars or lazy vals can't:
689690
// Source: http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.5.3

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

+1-7
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,9 @@ trait ScalaSettings extends AbsScalaSettings
141141
val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases.")
142142
val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
143143
val reporter = StringSetting ("-Xreporter", "classname", "Specify a custom reporter for compiler messages.", "scala.tools.nsc.reporters.ConsoleReporter")
144-
val strictInference = BooleanSetting ("-Xstrict-inference", "Don't infer known-unsound types")
145144
val source = ScalaVersionSetting ("-Xsource", "version", "Treat compiler input as Scala source for the specified version, see scala/bug#8126.", initial = ScalaVersion("2.13"))
146145

147146
val XnoPatmatAnalysis = BooleanSetting ("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.")
148-
val XfullLubs = BooleanSetting ("-Xfull-lubs", "Retains pre 2.10 behavior of less aggressive truncation of least upper bounds.")
149147

150148
val XmixinForceForwarders = ChoiceSetting(
151149
name = "-Xmixin-force-forwarders",
@@ -187,8 +185,6 @@ trait ScalaSettings extends AbsScalaSettings
187185
/**
188186
* -Y "Private" settings
189187
*/
190-
val overrideObjects = BooleanSetting ("-Yoverride-objects", "Allow member objects to be overridden.")
191-
val overrideVars = BooleanSetting ("-Yoverride-vars", "Allow vars to be overridden.")
192188
val Yhelp = BooleanSetting ("-Y", "Print a synopsis of private options.")
193189
val breakCycles = BooleanSetting ("-Ybreak-cycles", "Attempt to break cycles encountered during typing")
194190
val browse = PhasesSetting ("-Ybrowse", "Browse the abstract syntax tree after")
@@ -203,7 +199,6 @@ trait ScalaSettings extends AbsScalaSettings
203199
val Ynogenericsig = BooleanSetting ("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.")
204200
val noimports = BooleanSetting ("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
205201
val nopredef = BooleanSetting ("-Yno-predef", "Compile without importing Predef.")
206-
val noAdaptedArgs = BooleanSetting ("-Yno-adapted-args", "Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.")
207202
val Yrecursion = IntSetting ("-Yrecursion", "Set recursion depth used when locking symbols.", 0, Some((0, Int.MaxValue)), (_: String) => None)
208203
val Xshowtrees = BooleanSetting ("-Yshow-trees", "(Requires -Xprint:) Print detailed ASTs in formatted form.")
209204
val XshowtreesCompact
@@ -223,14 +218,13 @@ trait ScalaSettings extends AbsScalaSettings
223218
val Yreifycopypaste = BooleanSetting ("-Yreify-copypaste", "Dump the reified trees in copypasteable representation.")
224219
val Ymacroexpand = ChoiceSetting ("-Ymacro-expand", "policy", "Control expansion of macros, useful for scaladoc and presentation compiler.", List(MacroExpand.Normal, MacroExpand.None, MacroExpand.Discard), MacroExpand.Normal)
225220
val Ymacronoexpand = BooleanSetting ("-Ymacro-no-expand", "Don't expand macros. Might be useful for scaladoc and presentation compiler, but will crash anything which uses macros and gets past typer.") withDeprecationMessage(s"Use ${Ymacroexpand.name}:${MacroExpand.None}") withPostSetHook(_ => Ymacroexpand.value = MacroExpand.None)
221+
val YmacroAnnotations = BooleanSetting ("-Ymacro-annotations", "Enable support for macro annotations, formerly in macro paradise.")
226222
val Yreplsync = BooleanSetting ("-Yrepl-sync", "Do not use asynchronous code for repl startup")
227223
val Yreplclassbased = BooleanSetting ("-Yrepl-class-based", "Use classes to wrap REPL snippets instead of objects")
228224
val Yreploutdir = StringSetting ("-Yrepl-outdir", "path", "Write repl-generated classfiles to given output directory (use \"\" to generate a temporary dir)" , "")
229-
val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overridden methods.")
230225
val YdisableFlatCpCaching = BooleanSetting ("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
231226
val YcachePluginClassLoader = CachePolicy.setting("plugin", "compiler plugins")
232227
val YcacheMacroClassLoader = CachePolicy.setting("macro", "macros")
233-
val Yvirtpatmat = BooleanSetting ("-Yvirtpatmat", "Enable pattern matcher virtualization")
234228

235229
val exposeEmptyPackage = BooleanSetting ("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
236230
val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "method")

src/compiler/scala/tools/nsc/transform/patmat/MatchCodeGen.scala

-38
Original file line numberDiff line numberDiff line change
@@ -100,44 +100,6 @@ trait MatchCodeGen extends Interface {
100100
}
101101
}
102102

103-
trait PureMatchMonadInterface extends MatchMonadInterface {
104-
val matchStrategy: Tree
105-
import CODE._
106-
def _match(n: Name): SelectStart = matchStrategy DOT n
107-
108-
// TODO: error message
109-
private lazy val oneType = typer.typedOperator(_match(vpmName.one)).tpe
110-
override def pureType(tp: Type): Type = firstParamType(appliedType(oneType, tp :: Nil))
111-
}
112-
113-
trait PureCodegen extends CodegenCore with PureMatchMonadInterface {
114-
def codegen: AbsCodegen = pureCodegen
115-
116-
object pureCodegen extends CommonCodegen with Casegen { import CODE._
117-
//// methods in MatchingStrategy (the monad companion) -- used directly in translation
118-
// __match.runOrElse(`scrut`)(`scrutSym` => `matcher`)
119-
// TODO: consider catchAll, or virtualized matching will break in exception handlers
120-
def matcher(scrut: Tree, scrutSym: Symbol, restpe: Type)(cases: List[Casegen => Tree], matchFailGen: Option[Tree => Tree]): Tree =
121-
_match(vpmName.runOrElse) APPLY (scrut) APPLY (fun(scrutSym, cases map (f => f(this)) reduceLeft typedOrElse))
122-
123-
// __match.one(`res`)
124-
def one(res: Tree): Tree = (_match(vpmName.one)) (res)
125-
// __match.zero
126-
protected def zero: Tree = _match(vpmName.zero)
127-
// __match.guard(`c`, `then`)
128-
def guard(c: Tree, thenp: Tree): Tree = _match(vpmName.guard) APPLY (c, thenp)
129-
130-
//// methods in the monad instance -- used directly in translation
131-
// `prev`.flatMap(`b` => `next`)
132-
def flatMap(prev: Tree, b: Symbol, next: Tree): Tree = (prev DOT vpmName.flatMap)(fun(b, next))
133-
// `thisCase`.orElse(`elseCase`)
134-
def typedOrElse(thisCase: Tree, elseCase: Tree): Tree = (thisCase DOT vpmName.orElse) APPLY (elseCase)
135-
// __match.guard(`cond`, `res`).flatMap(`nextBinder` => `next`)
136-
def flatMapCond(cond: Tree, res: Tree, nextBinder: Symbol, next: Tree): Tree = flatMap(guard(cond, res), nextBinder, next)
137-
// __match.guard(`guardTree`, ()).flatMap((_: P[Unit]) => `next`)
138-
def flatMapGuard(guardTree: Tree, next: Tree): Tree = flatMapCond(guardTree, CODE.UNIT, freshSym(guardTree.pos, pureType(UnitTpe)), next)
139-
}
140-
}
141103

142104
trait OptimizedCodegen extends CodegenCore with TypedSubstitution with MatchMonadInterface {
143105
override def codegen: AbsCodegen = optimizedCodegen

0 commit comments

Comments
 (0)