Skip to content

Commit d5c2af2

Browse files
committed
Define spans of tpd.desugarIdentPrefix and TreeInfo.qualifier
Set the spans to the span of the original tree.
1 parent 55f07c4 commit d5c2af2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,12 +852,13 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
852852
}
853853

854854
/** The qualifier part of a Select or Ident.
855-
* For an Ident, this is the `This` of the current class.
855+
* For an Ident, this is the `This` of the current class, with the span of
856+
* the original tree.
856857
*/
857858
def qualifier(tree: Tree)(using Context): Tree = tree match {
858859
case Select(qual, _) => qual
859860
case tree: Ident => desugarIdentPrefix(tree)
860-
case _ => This(ctx.owner.enclosingClass.asClass)
861+
case _ => This(ctx.owner.enclosingClass.asClass).withSpan(tree.span)
861862
}
862863

863864
/** Is this a (potentially applied) selection of a member of a structural type

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,13 +1403,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
14031403
/** Recover identifier prefix (e.g. this) if it exists */
14041404
def desugarIdentPrefix(tree: Ident)(using Context): Tree = tree.tpe match {
14051405
case TermRef(prefix: TermRef, _) =>
1406-
prefix.info match
1407-
case mt: MethodType if mt.paramInfos.isEmpty && mt.resultType.typeSymbol.is(Module) =>
1408-
ref(mt.resultType.typeSymbol.sourceModule)
1409-
case _ =>
1410-
ref(prefix)
1406+
{ prefix.info match
1407+
case mt: MethodType if mt.paramInfos.isEmpty && mt.resultType.typeSymbol.is(Module) =>
1408+
ref(mt.resultType.typeSymbol.sourceModule)
1409+
case _ =>
1410+
ref(prefix)
1411+
}.withSpan(tree.span)
14111412
case TermRef(prefix: ThisType, _) =>
1412-
This(prefix.cls)
1413+
This(prefix.cls).withSpan(tree.span)
14131414
case _ =>
14141415
EmptyTree
14151416
}

0 commit comments

Comments
 (0)