@@ -62,6 +62,18 @@ object Interactive {
62
62
sourceSymbol(sym.owner)
63
63
else sym
64
64
65
+ /** Check if `tree` matches `sym`.
66
+ * This is the case if the symbol defined by `tree` equals `sym`,
67
+ * or the source symbol of tree equals sym,
68
+ * or `includeOverridden is true, and `sym` is overriden by `tree`.
69
+ */
70
+ def matchSymbol (tree : Tree , sym : Symbol , includeOverridden : Boolean )(implicit ctx : Context ): Boolean =
71
+ ( sym == tree.symbol
72
+ || sym.exists && sym == sourceSymbol(tree.symbol)
73
+ || includeOverridden && sym.name == tree.symbol.name &&
74
+ tree.symbol.owner.derivesFrom(sym.owner) && tree.symbol.overriddenSymbol(sym.owner.asClass) == sym
75
+ )
76
+
65
77
private def safely [T ](op : => List [T ]): List [T ] =
66
78
try op catch { case ex : TypeError => Nil }
67
79
@@ -175,19 +187,6 @@ object Interactive {
175
187
buf.toList
176
188
}
177
189
178
- /** Check if `tree` matches `sym`.
179
- * This is the case if one of the following is true:
180
- * (1) `sym` is the symbol of `tree`, or
181
- * (2) `sym` is a module value and its module class matches, or
182
- * (3) `includeOverridden is true, and `sym` is overriden by `tree`.
183
- */
184
- def matchSymbol (tree : Tree , sym : Symbol , includeOverridden : Boolean )(implicit ctx : Context ): Boolean =
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
- )
190
-
191
190
/** The reverse path to the node that closest encloses position `pos`,
192
191
* or `Nil` if no such path exists. If a non-empty path is returned it starts with
193
192
* the tree closest enclosing `pos` and ends with an element of `trees`.
0 commit comments