Skip to content

Commit b8fddaf

Browse files
authored
Merge pull request #5923 from dotty-staging/full-bootstrap
Full bootstrap: Use Dotty as the reference compiler
2 parents d39bca0 + ee7cc53 commit b8fddaf

File tree

361 files changed

+88
-74
lines changed

Some content is hidden

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

361 files changed

+88
-74
lines changed

.drone.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ pipeline:
5252
# sbt scripted tests are slow and only run on nightly or deployment
5353
event: [ tag, deployment ]
5454

55+
test_scala212:
56+
group: test
57+
image: lampepfl/dotty:2019-02-06
58+
commands:
59+
- cp -R . /tmp/5/ && cd /tmp/5/
60+
- ./project/scripts/sbt ";++2.12.8 ;compile ;test"
61+
5562
# DOCUMENTATION:
5663
documentation:
5764
image: lampepfl/dotty:2019-02-06

compiler/test/dotty/tools/TestSources.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ object TestSources {
6565
.map(_.toString)
6666
.toList
6767

68-
assert(sources.nonEmpty)
6968
sources
7069
}
7170
finally files.close()

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
2929

3030
// Positive tests ------------------------------------------------------------
3131

32+
@Test def posMacros: Unit = {
33+
implicit val testGroup: TestGroup = TestGroup("compilePosMacros")
34+
compileFilesInDir("tests/pos-macros", defaultOptions)
35+
}.checkCompile()
36+
3237
@Test def posWithCompiler: Unit = {
3338
implicit val testGroup: TestGroup = TestGroup("compilePosWithCompiler")
3439
compileFilesInDir("tests/pos-with-compiler", withCompilerOptions) +
@@ -69,13 +74,23 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
6974

7075
// Negative tests ------------------------------------------------------------
7176

72-
@Test def negAll: Unit = {
77+
@Test def negMacros: Unit = {
78+
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
79+
compileFilesInDir("tests/neg-macros", defaultOptions)
80+
}.checkExpectedErrors()
81+
82+
@Test def negWithCompiler: Unit = {
7383
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
7484
compileFilesInDir("tests/neg-with-compiler", withCompilerOptions)
7585
}.checkExpectedErrors()
7686

7787
// Run tests -----------------------------------------------------------------
7888

89+
@Test def runMacros: Unit = {
90+
implicit val testGroup: TestGroup = TestGroup("runMacros")
91+
compileFilesInDir("tests/run-macros", defaultOptions)
92+
}.checkRuns()
93+
7994
@Test def runWithCompiler: Unit = {
8095
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
8196
compileFilesInDir("tests/run-with-compiler", withCompilerOptions) +

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class CompilationTests extends ParallelTesting {
232232
Array("-Ycheck-reentrant", "-Yemit-tasty-in-class")
233233
)
234234

235-
val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped"))
235+
val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-3.x"), Paths.get("library/src-bootstrapped"))
236236
val librarySources = libraryDirs.flatMap(sources(_))
237237

238238
val lib =

compiler/test/dotty/tools/repl/ScriptedTests.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
package dotty.tools
1+
package dotty
2+
package tools
23
package repl
34

45
import java.io.{File => JFile}
56
import java.lang.System.{lineSeparator => EOL}
67

78
import org.junit.Assert._
89
import org.junit.Test
10+
import org.junit.experimental.categories.Category
911

1012
import scala.collection.mutable.ArrayBuffer
1113
import scala.io.Source
@@ -91,4 +93,7 @@ class ScriptedTests extends ReplTest with MessageRendering {
9193
@Test def replTests = scripts("/repl").foreach(testFile)
9294

9395
@Test def typePrinterTests = scripts("/type-printer").foreach(testFile)
96+
97+
@Category(Array(classOf[BootstrappedOnlyTests]))
98+
@Test def replMacrosTests = scripts("/repl-macros").foreach(testFile)
9499
}

library/src-bootstrapped/.keep

Whitespace-only changes.

library/src-non-bootstrapped/.keep

Whitespace-only changes.

project/Build.scala

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import scala.util.Properties.isJavaAtLeast
3030

3131
object Build {
3232
val scalacVersion = "2.12.8"
33+
val referenceVersion = "0.14.0-RC1"
3334

3435
val baseVersion = "0.15.0"
3536
val baseSbtDottyVersion = "0.3.2"
@@ -182,21 +183,31 @@ object Build {
182183
// Settings used for projects compiled only with Java
183184
lazy val commonJavaSettings = commonSettings ++ Seq(
184185
version := dottyVersion,
185-
scalaVersion := scalacVersion,
186+
scalaVersion := referenceVersion,
187+
// To be removed once we stop cross-compiling with Scala 2
188+
crossScalaVersions := Seq(referenceVersion, scalacVersion),
186189
// Do not append Scala versions to the generated artifacts
187190
crossPaths := false,
188191
// Do not depend on the Scala library
189192
autoScalaLibrary := false
190193
)
191194

192-
// Settings used when compiling dotty using Scala 2
193-
lazy val commonNonBootstrappedSettings = commonSettings ++ Seq(
195+
// Settings used when compiling dotty (both non-boostrapped and bootstrapped)
196+
lazy val commonDottySettings = commonSettings ++ Seq(
197+
// Manually set the standard library to use
198+
autoScalaLibrary := false
199+
)
200+
201+
// Settings used when compiling dotty with the reference compiler
202+
lazy val commonNonBootstrappedSettings = commonDottySettings ++ Seq(
194203
version := dottyNonBootstrappedVersion,
195-
scalaVersion := scalacVersion
204+
scalaVersion := referenceVersion,
205+
// To be removed once we stop cross-compiling with Scala 2
206+
crossScalaVersions := Seq(referenceVersion, scalacVersion)
196207
)
197208

198209
// Settings used when compiling dotty with a non-bootstrapped dotty
199-
lazy val commonBootstrappedSettings = commonSettings ++ Seq(
210+
lazy val commonBootstrappedSettings = commonDottySettings ++ Seq(
200211
version := dottyVersion,
201212
scalaVersion := dottyNonBootstrappedVersion,
202213

@@ -219,11 +230,6 @@ object Build {
219230
// sbt gets very unhappy if two projects use the same target
220231
target := baseDirectory.value / ".." / "out" / "bootstrap" / name.value,
221232

222-
// The non-bootstrapped dotty-library is not necessary when bootstrapping dotty
223-
autoScalaLibrary := false,
224-
// ...but scala-library is
225-
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,
226-
227233
// Compile using the non-bootstrapped and non-published dotty
228234
managedScalaInstance := false,
229235
scalaInstance := {
@@ -463,13 +469,20 @@ object Build {
463469
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
464470
else List()
465471

472+
val managedSrcDir = {
473+
// Populate the directory
474+
(managedSources in Compile).value
475+
476+
(sourceManaged in Compile).value
477+
}
478+
466479
val jarOpts = List(
467-
"-Ddotty.tests.dottyCompilerManagedSources=" + (sourceManaged in Compile).value,
480+
"-Ddotty.tests.dottyCompilerManagedSources=" + managedSrcDir,
468481
"-Ddotty.tests.classes.dottyInterfaces=" + jars("dotty-interfaces"),
469482
"-Ddotty.tests.classes.dottyLibrary=" + jars("dotty-library"),
470483
"-Ddotty.tests.classes.dottyCompiler=" + jars("dotty-compiler"),
471484
"-Ddotty.tests.classes.compilerInterface=" + findLib(attList, "compiler-interface"),
472-
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library"),
485+
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library-"),
473486
"-Ddotty.tests.classes.scalaAsm=" + findLib(attList, "scala-asm"),
474487
"-Ddotty.tests.classes.scalaXml=" + findLib(attList, "scala-xml"),
475488
"-Ddotty.tests.classes.jlineTerminal=" + findLib(attList, "jline-terminal"),
@@ -527,9 +540,6 @@ object Build {
527540
} else if (scalaLib == "") {
528541
println("Couldn't find scala-library on classpath, please run using script in bin dir instead")
529542
} else if (args.contains("-with-compiler")) {
530-
if (!isDotty.value) {
531-
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
532-
}
533543
val args1 = args.filter(_ != "-with-compiler")
534544
val asm = findLib(attList, "scala-asm")
535545
val dottyCompiler = jars("dotty-compiler")
@@ -578,9 +588,10 @@ object Build {
578588
)
579589

580590
def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn {
591+
val log = streams.value.log
581592
val attList = (dependencyClasspath in Runtime).value
582593
val jars = packageAll.value
583-
val scalaLib = findLib(attList, "scala-library")
594+
val scalaLib = findLib(attList, "scala-library-")
584595
val dottyLib = jars("dotty-library")
585596
val dottyCompiler = jars("dotty-compiler")
586597
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
@@ -599,8 +610,8 @@ object Build {
599610
var extraClasspath = s"$scalaLib${File.pathSeparator}$dottyLib"
600611
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += s"${File.pathSeparator}."
601612
if (args0.contains("-with-compiler")) {
602-
if (!isDotty.value) {
603-
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
613+
if (scalaVersion.value == referenceVersion) {
614+
log.error("-with-compiler should only be used with a bootstrapped compiler")
604615
}
605616
extraClasspath += s"${File.pathSeparator}$dottyCompiler"
606617
}
@@ -664,15 +675,32 @@ object Build {
664675
// Settings shared between dotty-library and dotty-library-bootstrapped
665676
lazy val dottyLibrarySettings = Seq(
666677
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,
678+
679+
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
680+
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath),
681+
682+
// To be removed once we stop cross-compiling with Scala 2
683+
unmanagedSourceDirectories in Compile += {
684+
val baseDir = baseDirectory.value
685+
if (!isDotty.value)
686+
baseDir / "src-2.x"
687+
else
688+
baseDir / "src-3.x"
689+
},
690+
667691
// Add version-specific source directories:
668-
// - files in src-non-bootstrapped will only be compiled by the reference compiler (scalac)
692+
// - files in src-non-bootstrapped will only be compiled by the reference compiler
669693
// - files in src-bootstrapped will only be compiled by the current dotty compiler (non-bootstrapped and bootstrapped)
670-
unmanagedSourceDirectories in Compile += {
694+
unmanagedSourceDirectories in Compile ++= {
671695
val baseDir = baseDirectory.value
672-
if (isDotty.value)
673-
baseDir / "src-bootstrapped"
696+
if (isDotty.value) {
697+
if (scalaVersion.value == referenceVersion)
698+
Seq(baseDir / "src-non-bootstrapped")
699+
else
700+
Seq(baseDir / "src-bootstrapped")
701+
}
674702
else
675-
baseDir / "src-non-bootstrapped"
703+
Seq()
676704
}
677705
)
678706

@@ -949,8 +977,12 @@ object Build {
949977
val updateCommunityBuild = taskKey[Unit]("Updates the community build.")
950978

951979
lazy val `community-build` = project.in(file("community-build")).
952-
settings(commonNonBootstrappedSettings).
980+
settings(commonSettings).
953981
settings(
982+
scalaVersion := referenceVersion,
983+
// To be removed once we stop cross-compiling with Scala 2
984+
crossScalaVersions := Seq(referenceVersion, scalacVersion),
985+
954986
prepareCommunityBuild := {
955987
(publishLocal in `dotty-sbt-bridge`).value
956988
(publishLocal in `dotty-interfaces`).value
@@ -1095,11 +1127,7 @@ object Build {
10951127
settings(dottyCompilerSettings)
10961128

10971129
def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings.
1098-
settings(dottyLibrarySettings).
1099-
bootstrappedSettings(
1100-
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
1101-
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath)
1102-
)
1130+
settings(dottyLibrarySettings)
11031131

11041132
def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings.
11051133
dependsOn(dottyCompiler, dottyCompiler % "test->test").
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/run/i5533b/Macro_1.scala renamed to tests/run-macros/i5533b/Macro_1.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ object scalatest {
88
inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)}
99

1010
def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = {
11-
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
1211
import refl._
1312
val tree = condition.unseal
1413
def exprStr: String = condition.show
@@ -30,4 +29,4 @@ object scalatest {
3029
}
3130
}
3231
}
33-
}
32+
}
File renamed without changes.

tests/run/i5536/Macro_1.scala renamed to tests/run-macros/i5536/Macro_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ object scalatest {
66

77
def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = {
88
import refl._
9-
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
109
val tree = condition.unseal
1110
def exprStr: String = condition.show
1211

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)