Skip to content

Omnibus tweaks #36

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

Merged
merged 4 commits into from
Nov 28, 2018
Merged
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: 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