diff options
author | Martin Odersky <odersky@gmail.com> | 2012-02-23 10:59:23 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-02-23 10:59:23 +0100 |
commit | bde711871a34d7987b8f7c090e7a7c12bdf58e22 (patch) | |
tree | 4ebab8beeb0f571f5ab9fbc898b7032eb104becc | |
parent | d1c0918e44ac4722138e6862892c5ed73f95e38b (diff) | |
download | scala-bde711871a34d7987b8f7c090e7a7c12bdf58e22.tar.gz scala-bde711871a34d7987b8f7c090e7a7c12bdf58e22.tar.bz2 scala-bde711871a34d7987b8f7c090e7a7c12bdf58e22.zip |
Made new automatic version of mkCast more robust for non-standard compilation setups by refining the logic what it means to be after a phase.
-rw-r--r-- | src/compiler/scala/reflect/internal/SymbolTable.scala | 10 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeGen.scala | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala index 2e799f914a..bd46a6f55d 100644 --- a/src/compiler/scala/reflect/internal/SymbolTable.scala +++ b/src/compiler/scala/reflect/internal/SymbolTable.scala @@ -41,7 +41,7 @@ abstract class SymbolTable extends api.Universe /** Override with final implementation for inlining. */ def debuglog(msg: => String): Unit = if (settings.debug.value) log(msg) def debugwarn(msg: => String): Unit = if (settings.debug.value) Console.err.println(msg) - + /** Overridden when we know more about what was happening during a failure. */ def supplementErrorMessage(msg: String): String = msg @@ -113,6 +113,10 @@ abstract class SymbolTable extends api.Universe final def period(rid: RunId, pid: Phase#Id): Period = (currentRunId << 8) + pid + /** Are we later than given phase in compilation? */ + final def isAtPhaseAfter(p: Phase) = + p != NoPhase && phase.id > p.id + /** Perform given operation at given phase. */ @inline final def atPhase[T](ph: Phase)(op: => T): T = { val current = phase @@ -125,7 +129,7 @@ abstract class SymbolTable extends api.Universe atPhase(ph.next)(op) @inline final def atPhaseNotLaterThan[T](target: Phase)(op: => T): T = - if (target != NoPhase && phase.id > target.id) atPhase(target)(op) else op + if (isAtPhaseAfter(target)) atPhase(target)(op) else op final def isValid(period: Period): Boolean = period != 0 && runId(period) == currentRunId && { @@ -276,7 +280,7 @@ abstract class SymbolTable extends api.Universe /** The phase which has given index as identifier. */ val phaseWithId: Array[Phase] - + /** Is this symbol table part of reflexive mirror? In this case * operations need to be made thread safe. */ diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index 4e2c906cde..061cbc33f3 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -199,7 +199,9 @@ abstract class TreeGen extends reflect.internal.TreeGen { debuglog("casting " + tree + ":" + tree.tpe + " to " + pt + " at phase: " + phase) assert(!tree.tpe.isInstanceOf[MethodType], tree) assert(pt eq pt.normalize, tree +" : "+ debugString(pt) +" ~>"+ debugString(pt.normalize)) - atPos(tree.pos)(mkAsInstanceOf(tree, pt, any = !phase.next.erasedTypes, wrapInApply = phase.id > currentRun.uncurryPhase.id)) + atPos(tree.pos) { + mkAsInstanceOf(tree, pt, any = !phase.next.erasedTypes, wrapInApply = isAtPhaseAfter(currentRun.uncurryPhase)) + } } /** Generate a cast for tree Tree representing Array with |