From faf347de363c19fb6e21ae5bfbe777536d37f23e Mon Sep 17 00:00:00 2001 From: Mike Skells Date: Mon, 26 Nov 2018 20:27:33 +0000 Subject: [PATCH 1/4] fix compile --- test/junit/scala/tools/nsc/classpath/ClassPluginTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/junit/scala/tools/nsc/classpath/ClassPluginTest.scala b/test/junit/scala/tools/nsc/classpath/ClassPluginTest.scala index 514294e8e8c1..346c58d9ca6b 100644 --- a/test/junit/scala/tools/nsc/classpath/ClassPluginTest.scala +++ b/test/junit/scala/tools/nsc/classpath/ClassPluginTest.scala @@ -26,7 +26,7 @@ class ClassPluginTest extends BytecodeTesting { // ... and this one to read them with a ClassPathPlugin object symbolTable extends SymbolTableForUnitTesting { val fakeClasses = Map( - "fake.C" -> ScalaClass("fake.C", pickleOf("package fake; class C { def foo = 42 }")) + "fake.C" -> ScalaClass("fake.C", () => pickleOf("package fake; class C { def foo = 42 }")) ) private val fakes = new VirtualDirectory("fakes", None) fakes.subdirectoryNamed("fake").fileNamed("C.class") From acf26b0d9d3455ddb0e2ead7c1f40df99fe5841e Mon Sep 17 00:00:00 2001 From: Mike Skells Date: Mon, 26 Nov 2018 23:08:45 +0000 Subject: [PATCH 2/4] avoid a few cycles --- src/compiler/scala/tools/nsc/CompilationUnits.scala | 2 +- src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index 159021bdacaf..af9bbc75dd28 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -153,7 +153,7 @@ trait CompilationUnits { global: Global => final def comment(pos: Position, msg: String): Unit = {} /** Is this about a .java source file? */ - lazy val isJava = source.file.name.endsWith(".java") + val isJava = source.file.name.endsWith(".java") override def toString() = source.toString() } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 947b95f57baa..47014f76f98b 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -213,7 +213,7 @@ abstract class Pickler extends SubComponent { // initially, but seems not to work, as the bug shows). // Adding the LOCAL_CHILD is necessary to retain exhaustivity warnings under separate // compilation. See test neg/aladdin1055. - val parents = (if (sym.isTrait) List(definitions.ObjectTpe) else Nil) ::: List(sym.tpe) + val parents = if (sym.isTrait) List(definitions.ObjectTpe, sym.tpe) else List(sym.tpe) globals + sym.newClassWithInfo(tpnme.LOCAL_CHILD, parents, EmptyScope, pos = sym.pos) } From 6c361850b913aad403a7d0668d8b7806f163a9ff Mon Sep 17 00:00:00 2001 From: Mike Skells Date: Mon, 26 Nov 2018 23:09:16 +0000 Subject: [PATCH 3/4] typo --- src/compiler/scala/tools/nsc/backend/Platform.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/scala/tools/nsc/backend/Platform.scala b/src/compiler/scala/tools/nsc/backend/Platform.scala index e0d4d2c59d09..8975321d0011 100644 --- a/src/compiler/scala/tools/nsc/backend/Platform.scala +++ b/src/compiler/scala/tools/nsc/backend/Platform.scala @@ -57,7 +57,7 @@ trait Platform { * - Caching the ScalaSignature annotation contents, to avoid the cost of decompressing * and parsing the classfile, akin to the OpenJDK's .sig format for stripped class files. * - Starting a downstream compilation job immediately after the upstream job has completed - * the pickler phase ("Build Pipelineing") + * the pickler phase ("Build Pipelining") */ abstract class ClassPathPlugin { def info(file: AbstractFile, clazz: ClassSymbol): Option[ClassfileInfo] From 8c02036c7c284a54469869a122da0777e6449fba Mon Sep 17 00:00:00 2001 From: Mike Skells Date: Mon, 26 Nov 2018 23:09:44 +0000 Subject: [PATCH 4/4] pickle java --- src/compiler/scala/tools/nsc/Global.scala | 12 +++++++++--- .../scala/tools/nsc/symtab/classfile/Pickler.scala | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 1a4be86239aa..2c265c522272 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -405,12 +405,18 @@ class Global(var currentSettings: Settings, reporter0: Reporter) def apply(unit: CompilationUnit): Unit + // run only the phases needed + private[this] val runThisPhaseForJava: Boolean = shouldRunThisPhaseForJava + + protected def shouldRunThisPhaseForJava: Boolean = { + this.id > (if (createJavadoc) currentRun.typerPhase.id + else currentRun.namerPhase.id) + } + /** Is current phase cancelled on this unit? */ def cancelled(unit: CompilationUnit) = { - // run the typer only if in `createJavadoc` mode - val maxJavaPhase = if (createJavadoc) currentRun.typerPhase.id else currentRun.namerPhase.id if (Thread.interrupted()) reporter.cancelled = true - reporter.cancelled || unit.isJava && this.id > maxJavaPhase + reporter.cancelled || unit.isJava && runThisPhaseForJava } private def beforeUnit(unit: CompilationUnit): Unit = { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 47014f76f98b..4cec57aa3e92 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -90,6 +90,8 @@ abstract class Pickler extends SubComponent { throw e } } + + override protected def shouldRunThisPhaseForJava: Boolean = true //from some -Y ?? } private class Pickle(root: Symbol) extends PickleBuffer(new Array[Byte](4096), -1, 0) {