Skip to content

Commit db2dc1d

Browse files
authored
Merge pull request #36 from mkeskells/omnibus-tweaks
Omnibus tweaks
2 parents 520f9a5 + 8c02036 commit db2dc1d

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

src/compiler/scala/tools/nsc/CompilationUnits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ trait CompilationUnits { global: Global =>
153153
final def comment(pos: Position, msg: String): Unit = {}
154154

155155
/** Is this about a .java source file? */
156-
lazy val isJava = source.file.name.endsWith(".java")
156+
val isJava = source.file.name.endsWith(".java")
157157

158158
override def toString() = source.toString()
159159
}

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,18 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
405405

406406
def apply(unit: CompilationUnit): Unit
407407

408+
// run only the phases needed
409+
private[this] val runThisPhaseForJava: Boolean = shouldRunThisPhaseForJava
410+
411+
protected def shouldRunThisPhaseForJava: Boolean = {
412+
this.id > (if (createJavadoc) currentRun.typerPhase.id
413+
else currentRun.namerPhase.id)
414+
}
415+
408416
/** Is current phase cancelled on this unit? */
409417
def cancelled(unit: CompilationUnit) = {
410-
// run the typer only if in `createJavadoc` mode
411-
val maxJavaPhase = if (createJavadoc) currentRun.typerPhase.id else currentRun.namerPhase.id
412418
if (Thread.interrupted()) reporter.cancelled = true
413-
reporter.cancelled || unit.isJava && this.id > maxJavaPhase
419+
reporter.cancelled || unit.isJava && runThisPhaseForJava
414420
}
415421

416422
private def beforeUnit(unit: CompilationUnit): Unit = {

src/compiler/scala/tools/nsc/backend/Platform.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ trait Platform {
5757
* - Caching the ScalaSignature annotation contents, to avoid the cost of decompressing
5858
* and parsing the classfile, akin to the OpenJDK's .sig format for stripped class files.
5959
* - Starting a downstream compilation job immediately after the upstream job has completed
60-
* the pickler phase ("Build Pipelineing")
60+
* the pickler phase ("Build Pipelining")
6161
*/
6262
abstract class ClassPathPlugin {
6363
def info(file: AbstractFile, clazz: ClassSymbol): Option[ClassfileInfo]

src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ abstract class Pickler extends SubComponent {
9090
throw e
9191
}
9292
}
93+
94+
override protected def shouldRunThisPhaseForJava: Boolean = true //from some -Y ??
9395
}
9496

9597
private class Pickle(root: Symbol) extends PickleBuffer(new Array[Byte](4096), -1, 0) {
@@ -213,7 +215,7 @@ abstract class Pickler extends SubComponent {
213215
// initially, but seems not to work, as the bug shows).
214216
// Adding the LOCAL_CHILD is necessary to retain exhaustivity warnings under separate
215217
// compilation. See test neg/aladdin1055.
216-
val parents = (if (sym.isTrait) List(definitions.ObjectTpe) else Nil) ::: List(sym.tpe)
218+
val parents = if (sym.isTrait) List(definitions.ObjectTpe, sym.tpe) else List(sym.tpe)
217219
globals + sym.newClassWithInfo(tpnme.LOCAL_CHILD, parents, EmptyScope, pos = sym.pos)
218220
}
219221

test/junit/scala/tools/nsc/classpath/ClassPluginTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ClassPluginTest extends BytecodeTesting {
2626
// ... and this one to read them with a ClassPathPlugin
2727
object symbolTable extends SymbolTableForUnitTesting {
2828
val fakeClasses = Map(
29-
"fake.C" -> ScalaClass("fake.C", pickleOf("package fake; class C { def foo = 42 }"))
29+
"fake.C" -> ScalaClass("fake.C", () => pickleOf("package fake; class C { def foo = 42 }"))
3030
)
3131
private val fakes = new VirtualDirectory("fakes", None)
3232
fakes.subdirectoryNamed("fake").fileNamed("C.class")

0 commit comments

Comments
 (0)