Skip to content

Commit 6e8933c

Browse files
authored
Merge pull request #1896 from dotty-staging/fix/bootstrap
Add sbt-based bootstrap
2 parents d5201d3 + fc2f931 commit 6e8933c

File tree

18 files changed

+194
-146
lines changed

18 files changed

+194
-146
lines changed

.drone.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ pipeline:
55
commands:
66
- ln -s /var/cache/drone/scala-scala scala-scala
77
- ./scripts/update-scala-library
8-
- sbt -Ddotty.drone.mem=4096m -ivy /var/cache/drone/ivy2 "${TEST}"
8+
- sbt -J-Xmx4096m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -Ddotty.drone.mem=4096m -ivy /var/cache/drone/ivy2 "${TEST}"
99

1010
matrix:
1111
TEST:
1212
- test
13+
- ;publishLocal;dotty-bootstrapped/test
1314
- partest-only-no-bootstrap --show-diff --verbose
1415
- partest-only --show-diff --verbose

compiler/src/dotty/tools/dotc/config/JavaPlatform.scala

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class JavaPlatform extends Platform {
1717
if (currentClassPath.isEmpty)
1818
currentClassPath = Some(new PathResolver().result)
1919
val cp = currentClassPath.get
20-
//println(cp)
21-
//println("------------------")
2220
cp
2321
}
2422

compiler/src/dotty/tools/dotc/config/PathResolver.scala

+1-8
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,7 @@ class PathResolver(implicit ctx: Context) {
255255
def containers = Calculated.containers
256256

257257
lazy val result: JavaClassPath = {
258-
// Prioritize `dotty.jar` and `dotty-lib.jar` to shadow others
259-
val (dottyJars, others) =
260-
containers.partition(x => x.name.contains("dotty-lib.jar") || x.name.contains("dotty.jar"))
261-
// Then any jars with `dotty` in the name - putting them before scala-library
262-
val (dottyCp, remaining) =
263-
others.partition(_.name.contains("dotty-"))
264-
265-
val cp = new JavaClassPath((dottyJars ++ dottyCp ++ remaining).toIndexedSeq, context)
258+
val cp = new JavaClassPath(containers.toIndexedSeq, context)
266259

267260
if (settings.Ylogcp.value) {
268261
Console.println("Classpath built from " + settings.toConciseString(ctx.sstate))

compiler/src/dotty/tools/dotc/core/Definitions.scala

+11-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,17 @@ class Definitions {
319319
def staticsMethodRef(name: PreName) = ScalaStaticsModule.requiredMethodRef(name)
320320
def staticsMethod(name: PreName) = ScalaStaticsModule.requiredMethod(name)
321321

322-
lazy val DottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef")
322+
// Dotty deviation: we cannot use a lazy val here because lazy vals in dotty
323+
// will return "null" when called recursively, see #1856.
324+
def DottyPredefModuleRef = {
325+
if (myDottyPredefModuleRef == null) {
326+
myDottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef")
327+
assert(myDottyPredefModuleRef != null)
328+
}
329+
myDottyPredefModuleRef
330+
}
331+
private[this] var myDottyPredefModuleRef: TermRef = _
332+
323333
def DottyPredefModule(implicit ctx: Context) = DottyPredefModuleRef.symbol
324334

325335
def Predef_eqAny(implicit ctx: Context) = DottyPredefModule.requiredMethod(nme.eqAny)

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ trait SymDenotations { this: Context =>
4545
else {
4646
val initial = denot.initial
4747
val firstPhaseId = initial.validFor.firstPhaseId.max(ctx.typerPhase.id)
48-
if ((initial ne denot) || ctx.phaseId != firstPhaseId)
49-
ctx.withPhase(firstPhaseId).stillValidInOwner(initial)
50-
else
48+
if ((initial ne denot) || ctx.phaseId != firstPhaseId) {
49+
ctx.withPhase(firstPhaseId).stillValidInOwner(initial) ||
50+
// Workaround #1895: A symbol might not be entered into an owner
51+
// until the second phase where it exists
52+
(denot.validFor.containsPhaseId(firstPhaseId + 1)) &&
53+
ctx.withPhase(firstPhaseId + 1).stillValidInOwner(initial)
54+
} else
5155
stillValidInOwner(denot)
5256
}
5357

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ object Scanners {
567567
nextChar()
568568
getOperatorRest()
569569
} else {
570-
error(f"illegal character '\\u${ch: Int}%04x'")
570+
// FIXME: Dotty deviation: f"" interpolator is not supported (#1814)
571+
error("illegal character '\\u%04x'".format(ch: Int))
571572
nextChar()
572573
}
573574
}

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private class ExtractDependenciesCollector(implicit val ctx: Context) extends tp
175175
override def traverse(tree: Tree)(implicit ctx: Context): Unit = {
176176
tree match {
177177
case Import(expr, selectors) =>
178-
def lookupImported(name: Name) = expr.tpe.member(name).symbol
178+
def lookupImported(name: Name) = expr.tpe.select(name).typeSymbol
179179
def addImported(name: Name) = {
180180
// importing a name means importing both a term and a type (if they exist)
181181
addDependency(lookupImported(name.toTermName))

compiler/src/dotty/tools/dotc/transform/ElimByName.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
8181
val inSuper = if (ctx.mode.is(Mode.InSuperCall)) InSuperCall else EmptyFlags
8282
val meth = ctx.newSymbol(
8383
ctx.owner, nme.ANON_FUN, Synthetic | Method | inSuper, MethodType(Nil, Nil, argType))
84-
Closure(meth, _ => arg.changeOwner(ctx.owner, meth))
84+
Closure(meth, _ =>
85+
atGroupEnd { implicit ctx: Context =>
86+
arg.changeOwner(ctx.owner, meth)
87+
}
88+
)
8589
}
8690
ref(defn.dummyApply).appliedToType(argType).appliedTo(argFun)
8791
case _ =>

compiler/src/dotty/tools/dotc/transform/ExtensionMethods.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
6363
// not generate them again.
6464
if (!(valueClass is Scala2x)) ctx.atPhase(thisTransformer) { implicit ctx =>
6565
for (decl <- valueClass.classInfo.decls) {
66-
if (isMethodWithExtension(decl))
67-
decls1.enter(createExtensionMethod(decl, moduleClassSym.symbol))
66+
if (isMethodWithExtension(decl)) {
67+
val meth = createExtensionMethod(decl, moduleClassSym.symbol)
68+
decls1.enter(meth)
69+
// Workaround #1895: force denotation of `meth` to be
70+
// at phase where `meth` is entered into the decls of a class
71+
meth.denot(ctx.withPhase(thisTransformer.next))
72+
}
6873
}
6974
}
7075

compiler/src/dotty/tools/dotc/typer/ImportInfo.scala

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ object ImportInfo {
3030
class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree],
3131
symNameOpt: Option[TermName], val isRootImport: Boolean = false)(implicit ctx: Context) {
3232

33-
lazy val sym = symf
33+
// Dotty deviation: we cannot use a lazy val here for the same reason
34+
// that we cannot use one for `DottyPredefModuleRef`.
35+
def sym = {
36+
if (mySym == null) {
37+
mySym = symf
38+
assert(mySym != null)
39+
}
40+
mySym
41+
}
42+
private[this] var mySym: Symbol = _
3443

3544
/** The (TermRef) type of the qualifier of the import clause */
3645
def site(implicit ctx: Context): Type = {

compiler/test/dotc/build.scala

-40
This file was deleted.

compiler/test/dotc/tests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class tests extends CompilerTest {
6161
List("-classpath", paths)
6262
}
6363

64-
implicit val defaultOptions = noCheckOptions ++ {
64+
implicit val defaultOptions: List[String] = noCheckOptions ++ {
6565
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
6666
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
6767
} ++ checkOptions ++ classPath

compiler/test/dotty/Jars.scala

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
package dotty
22

3-
/** Jars used when compiling test, defaults to sbt locations */
3+
/** Jars used when compiling test, normally set from the sbt build */
44
object Jars {
5-
val dottyLib: String = sys.env.get("DOTTY_LIB") getOrElse {
6-
"../library/target/scala-2.11/dotty-library_2.11-0.1.1-SNAPSHOT.jar"
7-
}
5+
val dottyLib: String = sys.env.get("DOTTY_LIB")
6+
.getOrElse(sys.props("dotty.tests.classes.library"))
87

9-
val dottyCompiler: String = sys.env.get("DOTTY_COMPILER") getOrElse {
10-
"./target/scala-2.11/dotty-compiler_2.11-0.1.1-SNAPSHOT.jar"
11-
}
8+
val dottyCompiler: String = sys.env.get("DOTTY_COMPILER")
9+
.getOrElse(sys.props("dotty.tests.classes.compiler"))
1210

13-
val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE") getOrElse {
14-
"../interfaces/target/dotty-interfaces-0.1.1-SNAPSHOT.jar"
15-
}
11+
val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE")
12+
.getOrElse(sys.props("dotty.tests.classes.interfaces"))
1613

17-
val dottyExtras: List[String] = sys.env.get("DOTTY_EXTRAS")
14+
val dottyExtras: List[String] = Option(sys.env.get("DOTTY_EXTRAS")
15+
.getOrElse(sys.props("dotty.tests.extraclasspath")))
1816
.map(_.split(":").toList).getOrElse(Nil)
1917

2018
val dottyReplDeps: List[String] = dottyLib :: dottyExtras

compiler/test/dotty/partest/DPConsoleRunner.scala

+11-6
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
202202
import FileManager.joinPaths
203203
// compile using command-line javac compiler
204204
val args = Seq(
205-
javacCmdPath,
205+
suiteRunner.javacCmdPath, // FIXME: Dotty deviation just writing "javacCmdPath" doesn't work
206206
"-d",
207207
outDir.getAbsolutePath,
208208
"-classpath",
@@ -300,11 +300,11 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
300300
// Don't get confused, the neg test passes when compilation fails for at
301301
// least one round (optionally checking the number of compiler errors and
302302
// compiler console output)
303-
case class CompFailed() extends NegTestState
303+
case object CompFailed extends NegTestState
304304
// the neg test fails when all rounds return either of these:
305305
case class CompFailedButWrongNErr(expected: String, found: String) extends NegTestState
306-
case class CompFailedButWrongDiff() extends NegTestState
307-
case class CompSucceeded() extends NegTestState
306+
case object CompFailedButWrongDiff extends NegTestState
307+
case object CompSucceeded extends NegTestState
308308

309309
def nerrIsOk(reason: String) = {
310310
val nerrFinder = """compilation failed with (\d+) errors""".r
@@ -350,7 +350,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
350350
if (existsNerr) false
351351
else {
352352
val existsDiff = failureStates.exists({
353-
case CompFailedButWrongDiff() =>
353+
case CompFailedButWrongDiff =>
354354
nextTestActionFailing(s"output differs")
355355
true
356356
case _ =>
@@ -398,8 +398,13 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
398398
override def extraClasspath =
399399
suiteRunner.fileManager.asInstanceOf[DottyFileManager].extraJarList ::: super.extraClasspath
400400

401+
402+
// FIXME: Dotty deviation: error if return type is omitted:
403+
// overriding method cleanup in class Runner of type ()Unit;
404+
// method cleanup of type => Boolean | Unit has incompatible type
405+
401406
// override to keep class files if failed and delete clog if ok
402-
override def cleanup = if (lastState.isOk) {
407+
override def cleanup: Unit = if (lastState.isOk) {
403408
logFile.delete
404409
cLogFile.delete
405410
Directory(outDir).deleteRecursively

compiler/test/dotty/tools/dotc/parsing/ModifiersParsingTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import ast.untpd._
1010
import ast.{ Trees => d }
1111
import Parsers.Parser
1212
import util.SourceFile
13-
import core.Contexts.ContextBase
13+
import core.Contexts._
1414
import core.Flags
1515

1616
object ModifiersParsingTest {
17-
implicit val ctx = (new ContextBase).initialCtx
17+
implicit val ctx: Context = (new ContextBase).initialCtx
1818

1919
implicit def parse(code: String): Tree = {
2020
val (_, stats) = new Parser(new SourceFile("<meta>", code.toCharArray)).templateStatSeq()

library/test/dotty/ShowTests.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class ShowTests {
3535

3636
@Test def showCar = {
3737
case class Car(model: String, manufacturer: String, year: Int)
38-
implicit val showCar = new Show[Car] {
38+
implicit val showCar: Show[Car] = new Show[Car] {
3939
def show(c: Car) =
4040
"Car(" + c.model.show + ", " + c.manufacturer.show + ", " + c.year.show + ")"
4141
}
4242

4343
case class Shop(xs: List[Car], name: String)
44-
implicit val showShop = new Show[Shop] {
44+
implicit val showShop: Show[Shop] = new Show[Shop] {
4545
def show(sh: Shop) =
4646
"Shop(" + sh.xs.show + ", " + sh.name.show + ")"
4747
}

0 commit comments

Comments
 (0)