Skip to content

Commit a093709

Browse files
committed
Fix missing positions
1 parent 6cfbe45 commit a093709

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

compiler/src/dotty/tools/dotc/quoted/ExprFrontend.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ class ExprFrontend(putInClass: Boolean) extends FrontEnd {
3434
}
3535

3636
private def inClass(expr: Expr[_])(implicit ctx: Context): Tree = {
37-
val coord: Coord = NoCoord // TODO add positions
37+
val pos = Position(0)
3838
val assocFile = new PlainFile(Path("<quote>"))
3939

4040
val cls = ctx.newCompleteClassSymbol(defn.RootClass, nme.QUOTE.toTypeName, EmptyFlags,
41-
defn.ObjectType :: Nil, newScope, coord = coord, assocFile = assocFile).entered.asClass
41+
defn.ObjectType :: Nil, newScope, coord = pos, assocFile = assocFile).entered.asClass
4242
cls.enter(ctx.newDefaultConstructor(cls), EmptyScope)
43-
val meth = ctx.newSymbol(cls, nme.apply, Method, ExprType(defn.AnyType), coord = coord).entered
43+
val meth = ctx.newSymbol(cls, nme.apply, Method, ExprType(defn.AnyType), coord = pos).entered
4444

4545
val quoted = quotedToTree(expr)(ctx.withOwner(meth))
4646

4747
val run = DefDef(meth, quoted)
4848
val classTree = ClassDef(cls, DefDef(cls.primaryConstructor.asTerm), run :: Nil)
49-
PackageDef(ref(defn.RootPackage).asInstanceOf[Ident], classTree :: Nil)
49+
PackageDef(ref(defn.RootPackage).asInstanceOf[Ident], classTree :: Nil).withPos(pos)
5050
}
5151
}

compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ object PickledQuotes {
5353
*/
5454
private def encapsulateQuote(tree: Tree)(implicit ctx: Context): Tree = {
5555
val sym = ctx.newSymbol(ctx.owner, "'".toTermName, Synthetic, defn.AnyType, coord = tree.pos)
56-
val quotedVal = ValDef(sym, tree)
57-
PackageDef(ref(defn.RootPackage).asInstanceOf[Ident], quotedVal :: Nil)
56+
val quotedVal = ValDef(sym, tree).withPos(tree.pos)
57+
PackageDef(ref(defn.RootPackage).asInstanceOf[Ident], quotedVal :: Nil).withPos(tree.pos)
5858
}
5959

6060
// TASTY picklingtests/pos/quoteTest.scala

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ object Typer {
5858
}
5959

6060
/** Assert tree has a position, unless it is empty or a typed splice */
61-
def assertPositioned(tree: untpd.Tree)(implicit ctx: Context) = ()
62-
// if (!tree.isEmpty && !tree.isInstanceOf[untpd.TypedSplice] && ctx.typerState.isGlobalCommittable)
63-
// assert(tree.pos.exists, s"position not set for $tree # ${tree.uniqueId}")
61+
def assertPositioned(tree: untpd.Tree)(implicit ctx: Context) =
62+
if (!tree.isEmpty && !tree.isInstanceOf[untpd.TypedSplice] && ctx.typerState.isGlobalCommittable)
63+
assert(tree.pos.exists, s"position not set for $tree # ${tree.uniqueId}")
6464

6565
private val ExprOwner = new Property.Key[Symbol]
6666
private val InsertedApply = new Property.Key[Unit]

0 commit comments

Comments
 (0)