Skip to content

Fix the bootstrap (yet again) #1745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/config/JavaPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class JavaPlatform extends Platform {
if (currentClassPath.isEmpty)
currentClassPath = Some(new PathResolver().result)
val cp = currentClassPath.get
//println(cp)
//println("------------------")
cp
}

Expand Down
9 changes: 1 addition & 8 deletions compiler/src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,7 @@ class PathResolver(implicit ctx: Context) {
def containers = Calculated.containers

lazy val result: JavaClassPath = {
// Prioritize `dotty.jar` and `dotty-lib.jar` to shadow others
val (dottyJars, others) =
containers.partition(x => x.name.contains("dotty-lib.jar") || x.name.contains("dotty.jar"))
// Then any jars with `dotty` in the name - putting them before scala-library
val (dottyCp, remaining) =
others.partition(_.name.contains("dotty-"))

val cp = new JavaClassPath((dottyJars ++ dottyCp ++ remaining).toIndexedSeq, context)
val cp = new JavaClassPath(containers.toIndexedSeq, context)

if (settings.Ylogcp.value) {
Console.println("Classpath built from " + settings.toConciseString(ctx.sstate))
Expand Down
12 changes: 11 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,17 @@ class Definitions {
def staticsMethodRef(name: PreName) = ScalaStaticsModule.requiredMethodRef(name)
def staticsMethod(name: PreName) = ScalaStaticsModule.requiredMethod(name)

lazy val DottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef")
// Dotty deviation: we cannot use a lazy val here because lazy vals in dotty
// will return "null" when called recursively, see #1856.
def DottyPredefModuleRef = {
if (_DottyPredefModuleRef == null) {
_DottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef")
assert(_DottyPredefModuleRef != null)
}
_DottyPredefModuleRef
}
private[this] var _DottyPredefModuleRef: TermRef = _

def DottyPredefModule(implicit ctx: Context) = DottyPredefModuleRef.symbol

def Predef_eqAny(implicit ctx: Context) = DottyPredefModule.requiredMethod(nme.eqAny)
Expand Down
10 changes: 7 additions & 3 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ trait SymDenotations { this: Context =>
else {
val initial = denot.initial
val firstPhaseId = initial.validFor.firstPhaseId.max(ctx.typerPhase.id)
if ((initial ne denot) || ctx.phaseId != firstPhaseId)
ctx.withPhase(firstPhaseId).stillValidInOwner(initial)
else
if ((initial ne denot) || ctx.phaseId != firstPhaseId) {
ctx.withPhase(firstPhaseId).stillValidInOwner(initial) ||
// Workaround #1895: A symbol might not be entered into an owner
// until the second phase where it exists
(denot.validFor.containsPhaseId(firstPhaseId + 1)) &&
ctx.withPhase(firstPhaseId + 1).stillValidInOwner(initial)
} else
stillValidInOwner(denot)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ object Scanners {
nextChar()
getOperatorRest()
} else {
error(f"illegal character '\\u${ch: Int}%04x'")
error("illegal character '\\u%04x'".format(ch: Int))
nextChar()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private class ExtractDependenciesCollector(implicit val ctx: Context) extends tp
override def traverse(tree: Tree)(implicit ctx: Context): Unit = {
tree match {
case Import(expr, selectors) =>
def lookupImported(name: Name) = expr.tpe.member(name).symbol
def lookupImported(name: Name) = expr.tpe.select(name).typeSymbol
def addImported(name: Name) = {
// importing a name means importing both a term and a type (if they exist)
addDependency(lookupImported(name.toTermName))
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/ElimByName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
val inSuper = if (ctx.mode.is(Mode.InSuperCall)) InSuperCall else EmptyFlags
val meth = ctx.newSymbol(
ctx.owner, nme.ANON_FUN, Synthetic | Method | inSuper, MethodType(Nil, Nil, argType))
Closure(meth, _ => arg.changeOwner(ctx.owner, meth))
atGroupEnd { implicit ctx: Context =>
Closure(meth, _ => arg.changeOwner(ctx.owner, meth))
}
// Closure(meth, _ => arg.changeOwnerAfter(ctx.owner, methw, thisTransformer))
}
ref(defn.dummyApply).appliedToType(argType).appliedTo(argFun)
case _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ class ExtensionMethods extends MiniPhaseTransform with DenotTransformer with Ful
// not generate them again.
if (!(valueClass is Scala2x)) ctx.atPhase(thisTransformer) { implicit ctx =>
for (decl <- valueClass.classInfo.decls) {
if (isMethodWithExtension(decl))
decls1.enter(createExtensionMethod(decl, moduleClassSym.symbol))
if (isMethodWithExtension(decl)) {
val meth = createExtensionMethod(decl, moduleClassSym.symbol)
decls1.enter(meth)
// Workaround #1895: force denotation of `meth` to be
// at phase where `meth` is entered into the decls of a class
meth.denot(ctx.withPhase(thisTransformer.next))
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ object ImportInfo {
*/
class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree], val isRootImport: Boolean = false)(implicit ctx: Context) {

lazy val sym = symf
// Dotty deviation: we cannot use a lazy val here for the same reason
// that we cannot use one for `DottyPredefModuleRef`.
def sym = {
if (_sym == null) {
_sym = symf
assert(_sym != null)
}
_sym
}
private[this] var _sym: Symbol = _

/** The (TermRef) type of the qualifier of the import clause */
def site(implicit ctx: Context): Type = {
Expand Down
40 changes: 0 additions & 40 deletions compiler/test/dotc/build.scala

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class tests extends CompilerTest {
List("-classpath", paths)
}

implicit val defaultOptions = noCheckOptions ++ {
implicit val defaultOptions: List[String] = noCheckOptions ++ {
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
} ++ checkOptions ++ classPath
Expand Down
20 changes: 9 additions & 11 deletions compiler/test/dotty/Jars.scala
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package dotty

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

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

val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE") getOrElse {
"../interfaces/target/dotty-interfaces-0.1.1-SNAPSHOT.jar"
}
val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE")
.getOrElse(sys.props("dotty.tests.classes.interfaces"))

val dottyExtras: List[String] = sys.env.get("DOTTY_EXTRAS")
val dottyExtras: List[String] = Option(sys.env.get("DOTTY_EXTRAS")
.getOrElse(sys.props("dotty.tests.extraclasspath")))
.map(_.split(":").toList).getOrElse(Nil)

val dottyReplDeps: List[String] = dottyLib :: dottyExtras
Expand Down
17 changes: 11 additions & 6 deletions compiler/test/dotty/partest/DPConsoleRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
import FileManager.joinPaths
// compile using command-line javac compiler
val args = Seq(
javacCmdPath,
suiteRunner.javacCmdPath, // FIXME: Dotty deviation just writing "javacCmdPath" doesn't work
"-d",
outDir.getAbsolutePath,
"-classpath",
Expand Down Expand Up @@ -300,11 +300,11 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
// Don't get confused, the neg test passes when compilation fails for at
// least one round (optionally checking the number of compiler errors and
// compiler console output)
case class CompFailed() extends NegTestState
case object CompFailed extends NegTestState
// the neg test fails when all rounds return either of these:
case class CompFailedButWrongNErr(expected: String, found: String) extends NegTestState
case class CompFailedButWrongDiff() extends NegTestState
case class CompSucceeded() extends NegTestState
case object CompFailedButWrongDiff extends NegTestState
case object CompSucceeded extends NegTestState

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


// FIXME: Dotty deviation: error if return type is emitted:
// overriding method cleanup in class Runner of type ()Unit;
// method cleanup of type => Boolean | Unit has incompatible type

// override to keep class files if failed and delete clog if ok
override def cleanup = if (lastState.isOk) {
override def cleanup: Unit = if (lastState.isOk) {
logFile.delete
cLogFile.delete
Directory(outDir).deleteRecursively
Expand Down
3 changes: 2 additions & 1 deletion compiler/test/dotty/tools/ContextEscapeDetection.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.LinkedList;
import java.util.List;

public abstract class ContextEscapeDetection {
/*public abstract class ContextEscapeDetection {
public static class TestContext{
public TestContext(WeakReference<Contexts.Context> context, String testName) {
this.context = context;
Expand All @@ -34,3 +34,4 @@ public synchronized void clearContext() {
this.clearCtx();
}
}
*/
3 changes: 2 additions & 1 deletion compiler/test/dotty/tools/ContextEscapeDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.Assert;
import java.lang.ref.WeakReference;

public class ContextEscapeDetector extends RunListener {
/*public class ContextEscapeDetector extends RunListener {

//context can be captured by objects, eg NoDenotation
public static final int CONTEXTS_ALLOWED = 1;
Expand Down Expand Up @@ -106,3 +106,4 @@ private static synchronized void forceGCHeuristic2() {
}
}
}
*/
4 changes: 3 additions & 1 deletion compiler/test/dotty/tools/DottyTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import dotc.Compiler

import dotc.core.Phases.Phase

class DottyTest extends ContextEscapeDetection{
class DottyTest /*extends ContextEscapeDetection*/{

dotc.parsing.Scanners // initialize keywords

Expand All @@ -30,10 +30,12 @@ class DottyTest extends ContextEscapeDetection{
ctx
}

/*
override def getCtx: Context = ctx
override def clearCtx() = {
ctx = null
}
*/

private def compilerWithChecker(phase: String)(assertion:(tpd.Tree, Context) => Unit) = new Compiler {
override def phases = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import ast.untpd._
import ast.{ Trees => d }
import Parsers.Parser
import util.SourceFile
import core.Contexts.ContextBase
import core.Contexts._
import core.Flags

object ModifiersParsingTest {
implicit val ctx = (new ContextBase).initialCtx
implicit val ctx: Context = (new ContextBase).initialCtx

implicit def parse(code: String): Tree = {
val (_, stats) = new Parser(new SourceFile("<meta>", code.toCharArray)).templateStatSeq()
Expand Down
4 changes: 2 additions & 2 deletions library/test/dotty/ShowTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class ShowTests {

@Test def showCar = {
case class Car(model: String, manufacturer: String, year: Int)
implicit val showCar = new Show[Car] {
implicit val showCar: Show[Car] = new Show[Car] {
def show(c: Car) =
"Car(" + c.model.show + ", " + c.manufacturer.show + ", " + c.year.show + ")"
}

case class Shop(xs: List[Car], name: String)
implicit val showShop = new Show[Shop] {
implicit val showShop: Show[Shop] = new Show[Shop] {
def show(sh: Shop) =
"Shop(" + sh.xs.show + ", " + sh.name.show + ")"
}
Expand Down
Loading