diff options
author | Martin Odersky <odersky@gmail.com> | 2009-05-25 22:00:48 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-05-25 22:00:48 +0000 |
commit | c5aa57c2d573f0205615db6690139e0e4b555492 (patch) | |
tree | 3041ad7966799bcc4d69a78fd2a92beef76f7afc /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 213285991d73a80b322c55000c69633893dccb80 (diff) | |
download | scala-c5aa57c2d573f0205615db6690139e0e4b555492.tar.gz scala-c5aa57c2d573f0205615db6690139e0e4b555492.tar.bz2 scala-c5aa57c2d573f0205615db6690139e0e4b555492.zip |
new presentation compiler design
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 170e445458..7dc60b91dc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1653,29 +1653,38 @@ trait Typers { self: Analyzer => def typedStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = { val inBlock = exprOwner == context.owner + val localTarget = + context.unit != null && + context.unit.targetPos != NoPosition && + (stats exists (context.unit.targetPos includes _.pos)) def typedStat(stat: Tree): Tree = { if (context.owner.isRefinementClass && !treeInfo.isDeclaration(stat)) errorTree(stat, "only declarations allowed here") - stat match { - case imp @ Import(_, _) => - val imp0 = typedImport(imp) - if (imp0 ne null) { - context = context.makeNewImport(imp0) - imp0.symbol.initialize - } - EmptyTree - case _ => - val localTyper = if (inBlock || (stat.isDef && !stat.isInstanceOf[LabelDef])) this - else newTyper(context.make(stat, exprOwner)) - val result = checkDead(localTyper.typed(stat)) - if (treeInfo.isSelfOrSuperConstrCall(result)) { - context.inConstructorSuffix = true - if (treeInfo.isSelfConstrCall(result) && result.symbol.pos.offset.getOrElse(0) >= exprOwner.enclMethod.pos.offset.getOrElse(0)) - error(stat.pos, "called constructor's definition must precede calling constructor's definition") - } - result - } + else + stat match { + case imp @ Import(_, _) => + val imp0 = typedImport(imp) + if (imp0 ne null) { + context = context.makeNewImport(imp0) + imp0.symbol.initialize + } + EmptyTree + case _ => + if (localTarget && !(context.unit.targetPos includes stat.pos)) { + stat + } else { + val localTyper = if (inBlock || (stat.isDef && !stat.isInstanceOf[LabelDef])) this + else newTyper(context.make(stat, exprOwner)) + val result = checkDead(localTyper.typed(stat)) + if (treeInfo.isSelfOrSuperConstrCall(result)) { + context.inConstructorSuffix = true + if (treeInfo.isSelfConstrCall(result) && result.symbol.pos.offset.getOrElse(0) >= exprOwner.enclMethod.pos.offset.getOrElse(0)) + error(stat.pos, "called constructor's definition must precede calling constructor's definition") + } + result + } + } } def accesses(accessor: Symbol, accessed: Symbol) = @@ -3432,8 +3441,6 @@ trait Typers { self: Analyzer => } try { - if (settings.debug.value) - assert(pt ne null, tree)//debug if (context.retyping && (tree.tpe ne null) && (tree.tpe.isErroneous || !(tree.tpe <:< pt))) { tree.tpe = null @@ -3449,7 +3456,7 @@ trait Typers { self: Analyzer => val result = if (tree1.isEmpty) tree1 else adapt(tree1, mode, pt) if (printTypings) println("adapted "+tree1+":"+tree1.tpe+" to "+pt+", "+context.undetparams); //DEBUG // if ((mode & TYPEmode) != 0) println("type: "+tree1+" has type "+tree1.tpe) - if (phase.id == currentRun.typerPhase.id) pollForHighPriorityJob() + if (phase.id == currentRun.typerPhase.id) signalDone(context.asInstanceOf[analyzer.Context], tree, result) result } catch { case ex: TypeError => |