Skip to content

Commit f24190d

Browse files
committed
Fix position of implicit conversions, eta-expansion and module vals
Synthetic trees should get zero-extent positions so that they don't get returned by Interactive#pathTo. This makes it easier to show information related to non-synthetic trees in IDEs.
1 parent 2ada3f6 commit f24190d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ object desugar {
548548
val clsRef = Ident(clsName)
549549
val modul = ValDef(moduleName, clsRef, New(clsRef, Nil))
550550
.withMods(mods | ModuleCreationFlags | mods.flags & AccessFlags)
551-
.withPos(mdef.pos)
551+
.withPos(mdef.pos.startPos)
552552
val ValDef(selfName, selfTpt, _) = impl.self
553553
val selfMods = impl.self.mods
554554
if (!selfTpt.isEmpty) ctx.error(ObjectMayNotHaveSelfType(mdef), impl.self.pos)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ object EtaExpansion {
139139
if (mt.paramInfos.length == xarity) mt.paramInfos map (_ => TypeTree())
140140
else mt.paramInfos map TypeTree
141141
val params = (mt.paramNames, paramTypes).zipped.map((name, tpe) =>
142-
ValDef(name, tpe, EmptyTree).withFlags(Synthetic | Param).withPos(tree.pos))
143-
var ids: List[Tree] = mt.paramNames map (name => Ident(name).withPos(tree.pos))
142+
ValDef(name, tpe, EmptyTree).withFlags(Synthetic | Param).withPos(tree.pos.startPos))
143+
var ids: List[Tree] = mt.paramNames map (name => Ident(name).withPos(tree.pos.startPos))
144144
if (mt.paramInfos.nonEmpty && mt.paramInfos.last.isRepeatedParam)
145145
ids = ids.init :+ repeated(ids.last)
146146
var body: Tree = Apply(lifted, ids)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ trait Implicits { self: Typer =>
743743
def typedImplicit(cand: Candidate)(implicit ctx: Context): SearchResult = track("typedImplicit") { ctx.traceIndented(i"typed implicit ${cand.ref}, pt = $pt, implicitsEnabled == ${ctx.mode is ImplicitsEnabled}", implicits, show = true) {
744744
assert(constr eq ctx.typerState.constraint)
745745
val ref = cand.ref
746-
var generated: Tree = tpd.ref(ref).withPos(pos)
746+
var generated: Tree = tpd.ref(ref).withPos(pos.startPos)
747747
if (!argument.isEmpty)
748748
generated = typedUnadapted(
749749
untpd.Apply(untpd.TypedSplice(generated), untpd.TypedSplice(argument) :: Nil),

0 commit comments

Comments
 (0)