Skip to content

Commit

Permalink
Merge pull request #36 from mkeskells/omnibus-tweaks
Browse files Browse the repository at this point in the history
Omnibus tweaks
  • Loading branch information
retronym authored Nov 28, 2018
2 parents 520f9a5 + 8c02036 commit db2dc1d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/CompilationUnits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
12 changes: 9 additions & 3 deletions src/compiler/scala/tools/nsc/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/backend/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -213,7 +215,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)
}

Expand Down
2 changes: 1 addition & 1 deletion test/junit/scala/tools/nsc/classpath/ClassPluginTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit db2dc1d

Please sign in to comment.