diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 7 | ||||
-rw-r--r-- | tests/pos/t2591.scala (renamed from tests/pending/pos/t2591.scala) | 0 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index d2a94e287..86d513fff 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -441,7 +441,7 @@ trait Implicits { self: Typer => lazy val funProto = fullProto match { case proto: ViewProto => - FunProto(dummyTreeOfType(proto.argType) :: Nil, proto.resultType, self) + FunProto(untpd.TypedSplice(dummyTreeOfType(proto.argType)) :: Nil, proto.resultType, self) case proto => proto } 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)) diff --git a/tests/pending/pos/t2591.scala b/tests/pos/t2591.scala index 47ae551bf..47ae551bf 100644 --- a/tests/pending/pos/t2591.scala +++ b/tests/pos/t2591.scala |