Skip to content

Commit e23d6ce

Browse files
committed
Rewrite matchSymbol
The previous version matched too much, as it as not comparing signatures. We no longer need to relate late-loaded symbols that should be the same as existsing ones, so the method can be simplified.
1 parent 952eb76 commit e23d6ce

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

compiler/src/dotty/tools/dotc/interactive/Interactive.scala

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,15 @@ object Interactive {
178178
/** Check if `tree` matches `sym`.
179179
* This is the case if one of the following is true:
180180
* (1) `sym` is the symbol of `tree`, or
181-
* (2) The two symbols have the same name and class owner, or
182-
* (3) `includeOverriden is true, and `sym` is overriden by `tree`.
183-
*
184-
* The reason for (2) is that if a symbol comes from a SourcefileLoader it is
185-
* different from the symbol that was referred to, until the next run is started.
181+
* (2) `sym` is a module value and its module class matches, or
182+
* (3) `includeOverridden is true, and `sym` is overriden by `tree`.
186183
*/
187184
def matchSymbol(tree: Tree, sym: Symbol, includeOverridden: Boolean)(implicit ctx: Context): Boolean =
188-
(sym == tree.symbol) ||
189-
sym.name == tree.symbol.name && sym.owner.isClass && sym.owner == tree.symbol.owner ||
190-
(includeOverridden && tree.symbol.allOverriddenSymbols.contains(sym))
191-
185+
( sym == tree.symbol
186+
|| sym.is(ModuleVal) && tree.symbol == sym.moduleClass
187+
|| includeOverridden && sym.name == tree.symbol.name && sym.owner.isClass &&
188+
tree.symbol.overriddenSymbol(sym.owner.asClass) == sym
189+
)
192190

193191
/** The reverse path to the node that closest encloses position `pos`,
194192
* or `Nil` if no such path exists. If a non-empty path is returned it starts with

0 commit comments

Comments
 (0)