summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-10-28 23:10:12 +0100
committerJason Zaugg <jzaugg@gmail.com>2012-10-28 23:21:33 +0100
commit2d9b65b8fce13166f7fd521e433e18039356c4db (patch)
tree280d753a3ca52c44a4f5dbc36285877e484650f3 /src/compiler/scala
parent74297159f5c4df42dcf6289f4daea79e7d4f7bb4 (diff)
downloadscala-2d9b65b8fce13166f7fd521e433e18039356c4db.tar.gz
scala-2d9b65b8fce13166f7fd521e433e18039356c4db.tar.bz2
scala-2d9b65b8fce13166f7fd521e433e18039356c4db.zip
Wider use and a new variant of typedPos.
It's safe to replace `localTyper.typed(atPos(pos)(tree))` with `localTyper.typedPos(pos)(tree)` given that we're all in the same cake and we'll get to the same `atPos`.
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Duplicators.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala17
4 files changed, 19 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index 2b0520592b..80900a1a0a 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -481,7 +481,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
/** The typer */
private var localTyper: erasure.Typer = _
- private def typedPos(pos: Position)(tree: Tree) = localTyper typed { atPos(pos)(tree) }
+ private def typedPos(pos: Position)(tree: Tree): Tree = localTyper.typedPos(pos)(tree)
private def localTyped(pos: Position, tree: Tree, pt: Type) = localTyper.typed(atPos(pos)(tree), pt)
/** Map lazy values to the fields they should null after initialization. */
diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
index 97e86d183e..aa507efe5a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
@@ -321,7 +321,9 @@ abstract class Duplicators extends Analyzer {
// we use the symbol name instead of the tree name because the symbol may have been
// name mangled, rendering the tree name obsolete
// log(tree)
- val t = super.typed(atPos(tree.pos)(Select(This(newClassOwner), tree.symbol.name)), mode, pt)
+ val t = super.typedPos(tree.pos, mode, pt) {
+ Select(This(newClassOwner), tree.symbol.name)
+ }
// log("typed to: " + t + "; tpe = " + t.tpe + "; " + inspectTpe(t.tpe))
t
@@ -331,7 +333,7 @@ abstract class Duplicators extends Analyzer {
val tree1 = This(newClassOwner)
// log("tree1: " + tree1)
debuglog("mapped " + tree + " to " + tree1)
- super.typed(atPos(tree.pos)(tree1), mode, pt)
+ super.typedPos(tree.pos, mode, pt)(tree1)
case This(_) =>
debuglog("selection on this, plain: " + tree)
@@ -368,7 +370,7 @@ abstract class Duplicators extends Analyzer {
cases
}
- super.typed(atPos(tree.pos)(Match(scrut, cases1)), mode, pt)
+ super.typedPos(tree.pos, mode, pt)(Match(scrut, cases1))
case EmptyTree =>
// no need to do anything, in particular, don't set the type to null, EmptyTree.tpe_= asserts
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 7852ff49e1..99301cebcf 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1172,7 +1172,7 @@ trait Implicits {
}
try {
- val tree1 = typed(atPos(pos.focus)(arg))
+ val tree1 = typedPos(pos.focus)(arg)
if (context.hasErrors) processMacroExpansionError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
else new SearchResult(tree1, EmptyTreeTypeSubstituter)
} catch {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 8e06588ed8..6a55b16275 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1049,7 +1049,9 @@ trait Typers extends Modes with Adaptations with Tags {
case other =>
other
}
- typed(atPos(tree.pos)(Select(qual setPos tree.pos.makeTransparent, nme.apply)), mode, pt)
+ typedPos(tree.pos, mode, pt) {
+ Select(qual setPos tree.pos.makeTransparent, nme.apply)
+ }
}
// begin adapt
@@ -1147,11 +1149,15 @@ trait Typers extends Modes with Adaptations with Tags {
if (sym == UnitClass && tree.tpe <:< AnyClass.tpe) { // (12)
if (settings.warnValueDiscard.value)
context.unit.warning(tree.pos, "discarded non-Unit value")
- return typed(atPos(tree.pos)(Block(List(tree), Literal(Constant()))), mode, pt)
+ return typedPos(tree.pos, mode, pt) {
+ Block(List(tree), Literal(Constant()))
+ }
} else if (isNumericValueClass(sym) && isNumericSubType(tree.tpe, pt)) {
if (settings.warnNumericWiden.value)
context.unit.warning(tree.pos, "implicit numeric widening")
- return typed(atPos(tree.pos)(Select(tree, "to" + sym.name)), mode, pt)
+ return typedPos(tree.pos, mode, pt) {
+ Select(tree, "to" + sym.name)
+ }
}
case AnnotatedType(_, _, _) if canAdaptAnnotations(tree, mode, pt) => // (13)
return typed(adaptAnnotations(tree, mode, pt), mode, pt)
@@ -2591,9 +2597,9 @@ trait Typers extends Modes with Adaptations with Tags {
def translated =
if (members.head eq EmptyTree) setError(tree)
else {
- val typedBlock = typed(atPos(tree.pos)(
+ val typedBlock = typedPos(tree.pos, mode, pt) {
Block(ClassDef(anonClass, NoMods, ListOfNil, ListOfNil, members, tree.pos.focus), atPos(tree.pos.focus)(New(anonClass.tpe)))
- ), mode, pt)
+ }
// Don't leak implementation details into the type, see SI-6575
if (isPartial && !typedBlock.isErrorTyped)
typedBlock modifyType (_ baseType PartialFunctionClass)
@@ -5502,6 +5508,7 @@ trait Typers extends Modes with Adaptations with Tags {
ret
}
+ def typedPos(pos: Position, mode: Int, pt: Type)(tree: Tree) = typed(atPos(pos)(tree), mode, pt)
def typedPos(pos: Position)(tree: Tree) = typed(atPos(pos)(tree))
// TODO: see if this formulation would impose any penalty, since
// it makes for a lot less casting.