Skip to content

Commit 17fa6d8

Browse files
committed
Add option to do outline typing, use this in PipelineMain
1 parent d832e6b commit 17fa6d8

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/compiler/scala/tools/nsc/PipelineMain.scala

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,35 @@ class PipelineMainClass {
8585
reporter.echo(command.usageMsg)
8686
reporter.echo(compiler.pluginOptionsHelp)
8787
} else {
88-
val run = new compiler.Run()
89-
run compile command.files
88+
println("outline typing")
89+
command.settings.Youtline.value = true
90+
command.settings.stopAfter.value = List("pickler")
91+
val run1 = new compiler.Run()
92+
run1 compile command.files
9093
reporter.finish()
94+
if (!reporter.hasErrors) {
95+
println("regular compilation")
96+
command.settings.Youtline.value = false
97+
command.settings.stopAfter.value = Nil
98+
val pickles = run1.symData
99+
val compiler2 = newCompiler(command.settings)
100+
val run2 = new compiler2.Run()
101+
run2 compile command.files
102+
compiler2.reporter.finish()
103+
}
104+
91105
}
92106
}
93107

94108

95-
def main(args: Array[String]): Unit = System.exit(if (process(args)) 0 else 1)
109+
def main(args: Array[String]): Unit = {
110+
for (i <- 1 to 10) {
111+
val result = process(args)
112+
if (!result)
113+
System.exit(1)
114+
}
115+
System.exit(0)
116+
}
96117
}
97118

98119
object PipelineMain extends PipelineMainClass {}

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ trait ScalaSettings extends AbsScalaSettings
234234
val YcacheMacroClassLoader = CachePolicy.setting("macro", "macros")
235235
val YpartialUnification = BooleanSetting ("-Ypartial-unification", "Enable partial unification in type constructor inference")
236236
val Yvirtpatmat = BooleanSetting ("-Yvirtpatmat", "Enable pattern matcher virtualization")
237+
val Youtline = BooleanSetting ("-Youtline", "Don't compile method bodies. Use together with `-Ystop-afer:pickler to generate the pickled signatures for all source files.")
237238

238239
val exposeEmptyPackage = BooleanSetting ("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
239240
val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "method")

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,8 +2037,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
20372037
}
20382038

20392039
// use typedValDef instead. this version is called after creating a new context for the ValDef
2040-
private def typedValDefImpl(vdef: ValDef) = {
2040+
private def typedValDefImpl(vdef: ValDef): ValDef = {
20412041
val sym = vdef.symbol.initialize
2042+
20422043
val typedMods = if (nme.isLocalName(sym.name) && sym.isPrivateThis && !vdef.mods.isPrivateLocal) {
20432044
// scala/bug#10009 This tree has been given a field symbol by `enterGetterSetter`, patch up the
20442045
// modifiers accordingly so that we can survive resetAttrs and retypechecking.
@@ -5830,7 +5831,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
58305831
final def transformedOrTyped(tree: Tree, mode: Mode, pt: Type): Tree = {
58315832
lookupTransformed(tree) match {
58325833
case Some(tree1) => tree1
5833-
case _ => typed(tree, mode, pt)
5834+
case _ => if (settings.Youtline.value) EmptyTree else typed(tree, mode, pt)
58345835
}
58355836
}
58365837
final def lookupTransformed(tree: Tree): Option[Tree] =

0 commit comments

Comments
 (0)