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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 8 deletions
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

Lines changed: 11 additions & 1 deletion
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

Lines changed: 7 additions & 3 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 7 additions & 2 deletions
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

Lines changed: 10 additions & 1 deletion
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 = {

0 commit comments

Comments
 (0)