aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-05-16 12:36:43 +0200
committerMartin Odersky <odersky@gmail.com>2014-05-30 14:38:12 +0200
commit4a071ad51e4ccc94c34e0fcbea84d48cd8bb214c (patch)
tree8ef056f85220cc6d9646b9d2903a4614c94f0aa2 /src/dotty/tools/dotc/typer/Typer.scala
parente42388682094c63055440c8915d8215935007584 (diff)
downloaddotty-4a071ad51e4ccc94c34e0fcbea84d48cd8bb214c.tar.gz
dotty-4a071ad51e4ccc94c34e0fcbea84d48cd8bb214c.tar.bz2
dotty-4a071ad51e4ccc94c34e0fcbea84d48cd8bb214c.zip
Fix of t2591.
Needed to wrap a dummyTreeOfType in a TypedSplice to prevent re-typechecking. (In fact, the "tree without pos" check revealed a deeper problem: DummyTrees of types could be typed again, but without the surrounding TypedSplice, the originally stored type would be forgotten and Null would be returned.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 3698c648c..e3683d2cf 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -46,6 +46,11 @@ object Typer {
val nothingBound = 0
def isImportPrec(prec: Int) = prec == namedImport || prec == wildImport
}
+
+ /** Assert tree has a position, unless it is empty or a typed splice */
+ def assertPositioned(tree: untpd.Tree)(implicit ctx: Context) =
+ if (!tree.isEmpty && !tree.isInstanceOf[untpd.TypedSplice] && ctx.typerState.isGlobalCommittable)
+ assert(tree.pos.exists, s"position not set for $tree # ${tree.uniqueId}")
}
class Typer extends Namer with TypeAssigner with Applications with Implicits with Inferencing with Checking {
@@ -953,7 +958,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = /*>|>*/ ctx.traceIndented (i"typing $tree", typr, show = true) /*<|<*/ {
- if (!tree.isEmpty && ctx.typerState.isGlobalCommittable) assert(tree.pos.exists, i"position not set for $tree")
+ assertPositioned(tree)
try adapt(typedUnadapted(tree, pt), pt, tree)
catch {
case ex: CyclicReference => errorTree(tree, cyclicErrorMsg(ex))