Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/scala/scala
Browse files Browse the repository at this point in the history
  • Loading branch information
paulp committed May 12, 2012
2 parents 255cd51 + f1d81c9 commit 50a7788
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
27 changes: 25 additions & 2 deletions src/compiler/scala/tools/nsc/Global.scala
Expand Up @@ -130,7 +130,28 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
object nodePrinters extends {
val global: Global.this.type = Global.this
} with NodePrinters {
var lastPrintedPhase: Phase = NoPhase
var lastPrintedSource: String = ""
infolevel = InfoLevel.Verbose

def showUnit(unit: CompilationUnit) {
print(" // " + unit.source)
if (unit.body == null) println(": tree is null")
else {
val source = util.stringFromWriter(w => newTreePrinter(w) print unit.body)

// treePrinter show unit.body
if (lastPrintedSource == source)
println(": tree is unchanged since " + lastPrintedPhase)
else {
lastPrintedPhase = phase.prev // since we're running inside "afterPhase"
lastPrintedSource = source
println("")
println(source)
println("")
}
}
}
}

def withInfoLevel[T](infolevel: nodePrinters.InfoLevel.Value)(op: => T) = {
Expand Down Expand Up @@ -1588,8 +1609,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
} // class Run

def printAllUnits() {
print("[[syntax trees at end of " + phase + "]]")
afterPhase(phase) { currentRun.units foreach (treePrinter.print(_)) }
print("[[syntax trees at end of %25s]]".format(phase))
afterPhase(phase)(currentRun.units foreach { unit =>
nodePrinters showUnit unit
})
}

/** We resolve the class/object ambiguity by passing a type/term name.
Expand Down
2 changes: 2 additions & 0 deletions test/files/run/t5037.check
@@ -0,0 +1,2 @@
true
false
18 changes: 18 additions & 0 deletions test/files/run/t5037.scala
@@ -0,0 +1,18 @@
object Test {
def main(args: Array[String]) {
val t = new Test
t.inner.foo()
}
}

class Test {
class Inner {
def foo() {
println(bar)
bar = false
println(bar)
}
}
val inner = new Inner
private[this] final var bar = true
}
2 changes: 1 addition & 1 deletion test/files/run/t5527.check
@@ -1,4 +1,4 @@
[[syntax trees at end of parser]]// Scala source: newSource1
[[syntax trees at end of parser]] // newSource1
package <empty> {
object UselessComments extends scala.AnyRef {
def <init>() = {
Expand Down
2 changes: 1 addition & 1 deletion test/files/specialized/SI-5005.check
@@ -1,4 +1,4 @@
[[syntax trees at end of specialize]]// Scala source: newSource1
[[syntax trees at end of specialize]] // newSource1
package <empty> {
class C2[@specialized(scala.Boolean) U >: Nothing <: Any] extends Object {
def <init>(): C2[U] = {
Expand Down

0 comments on commit 50a7788

Please sign in to comment.