Skip to content

Commit aa18455

Browse files
noti0na1WojciechMazur
authored andcommitted
Apply suggestions
[Cherry-picked d192e48]
1 parent 1578f06 commit aa18455

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
9797
ctx
9898

9999
override def prepareForSelect(tree: tpd.Select)(using Context): Context =
100-
val name = tree.getAttachment(OriginalName).orElse(Some(tree.name))
100+
val name = tree.removeAttachment(OriginalName).orElse(Some(tree.name))
101101
unusedDataApply(_.registerUsed(tree.symbol, name))
102102

103103
override def prepareForBlock(tree: tpd.Block)(using Context): Context =

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
620620
val checkedType = checkNotShadowed(ownType)
621621
val tree1 = checkedType match
622622
case checkedType: NamedType if !prefixIsElidable(checkedType) =>
623-
ref(checkedType).withSpan(tree.span).withAttachment(OriginalName, name)
623+
ref(checkedType).withSpan(tree.span)
624624
case _ =>
625625
tree.withType(checkedType)
626626
val tree2 = toNotNullTermRef(tree1, pt)
@@ -647,7 +647,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
647647
val selection = untpd.cpy.Select(tree)(qualifier, name)
648648
typed(selection, pt)
649649
else if rawType.exists then
650-
setType(ensureAccessible(rawType, superAccess = false, tree.srcPos))
650+
val ref = setType(ensureAccessible(rawType, superAccess = false, tree.srcPos))
651+
if ref.symbol.name != name then
652+
ref.withAttachment(OriginalName, name)
653+
else ref
651654
else if name == nme._scope then
652655
// gross hack to support current xml literals.
653656
// awaiting a better implicits based solution for library-supported xml

0 commit comments

Comments
 (0)