File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,8 @@ object NameOps {
146146
147147 /** Revert the expanded name. */
148148 def unexpandedName : N = likeSpacedN {
149- name.replace {
149+ name.replaceDeep {
150150 case ExpandedName (_, unexp) => unexp
151- case DerivedName (qual, info : QualifiedInfo ) => qual.unexpandedName.derived(info)
152151 }
153152 }
154153
Original file line number Diff line number Diff line change @@ -69,11 +69,18 @@ object Names {
6969
7070 /** Apply rewrite rule given by `f` to some part of this name, skipping and rewrapping
7171 * other decorators.
72- * Stops at `DerivedName`s with infos of kind ` QualifiedInfo` .
72+ * Stops at DerivedNames with infos of kind QualifiedInfo.
7373 * If `f` does not apply to any part, return name unchanged.
7474 */
7575 def replace (f : PartialFunction [Name , Name ]): ThisName
7676
77+ /** Same as replace, but does not stop at DerivedNames with infos of kind QualifiedInfo. */
78+ def replaceDeep (f : PartialFunction [Name , Name ]): ThisName =
79+ replace(f.orElse {
80+ case DerivedName (underlying, info : QualifiedInfo ) =>
81+ underlying.replaceDeep(f).derived(info)
82+ })
83+
7784 /** If partial function `f` is defined for some part of this name, apply it
7885 * in a Some, otherwise None.
7986 * Stops at derived names whose kind has `definesNewName = true`.
Original file line number Diff line number Diff line change @@ -486,15 +486,10 @@ object SymDenotations {
486486 def qualify (n : SimpleName ) =
487487 val qn = kind(prefix.toTermName, if (filler.isEmpty) n else termName(filler + n))
488488 if kind == FlatName && ! encl.is(JavaDefined ) then qn.compactified else qn
489- def expand (name : Name ): Name = name.replace {
490- case name : SimpleName => qualify(name)
491- case name @ DerivedName (qual, info : QualifiedInfo ) =>
492- expand(qual).derived(info)
493- // Keep the qualified name, so that it can be recovered later.
494- // An example where this matters is run/i15702.scala
489+ val fn = name.replaceDeep {
490+ case n : SimpleName => qualify(n)
495491 }
496- val fn = expand(name)
497- if (name.isTypeName) fn.toTypeName else fn.toTermName
492+ if name.isTypeName then fn.toTypeName else fn.toTermName
498493 }
499494
500495 /** The encoded flat name of this denotation, where joined names are separated by `separator` characters. */
You can’t perform that action at this time.
0 commit comments