aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-29 18:36:18 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-29 18:36:18 +0100
commit0553f08eaeee1f9ac7ef6c28b341a92e0fb452e3 (patch)
tree497e40b6b4c6ee37f7a24259296a15d50371fd91 /src/dotty/tools/dotc/typer/Typer.scala
parent3f39cd8e15c321cf6ac97a0137087f7c2d69ce60 (diff)
downloaddotty-0553f08eaeee1f9ac7ef6c28b341a92e0fb452e3.tar.gz
dotty-0553f08eaeee1f9ac7ef6c28b341a92e0fb452e3.tar.bz2
dotty-0553f08eaeee1f9ac7ef6c28b341a92e0fb452e3.zip
Tightening of position handlng
1) endPos works now even for NoPosition. 2) On the other hand, there's an assertion in Typer.typed which requires every non-empty tree that's type checked in a globally committable context to have a defined position. Some fixes were needed to make the tests pass the new assert.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 85724b1ee..be84d1bea 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -492,7 +492,7 @@ class Typer extends Namer with Applications with Implicits {
def typedIf(tree: untpd.If, pt: Type)(implicit ctx: Context) = track("typedIf") {
val cond1 = typed(tree.cond, defn.BooleanType)
val thenp1 = typed(tree.thenp, pt)
- val elsep1 = typed(tree.elsep orElse untpd.unitLiteral, pt)
+ val elsep1 = typed(tree.elsep orElse untpd.unitLiteral withPos tree.pos, pt)
cpy.If(tree, cond1, thenp1, elsep1).withType(thenp1.tpe | elsep1.tpe)
}
@@ -952,6 +952,7 @@ class Typer extends Namer with Applications with Implicits {
}
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = ctx.traceIndented (s"typing ${tree.show}", show = true) {
+ if (!tree.isEmpty && ctx.typerState.isGlobalCommittable) assert(tree.pos.exists, tree)
try adapt(typedUnadapted(tree, pt), pt)
catch {
case ex: CyclicReference => errorTree(tree, cyclicErrorMsg(ex))