@@ -232,7 +232,7 @@ object Matcher {
232
232
scrutinee =?= expr2
233
233
234
234
/* Match selection */
235
- case (ref : Ref , Select (qual2, _)) if symbolMatch(scrutinee, pattern) =>
235
+ case (ref : Ref , Select (qual2, _)) if symbolMatch(scrutinee. asInstanceOf , pattern. asInstanceOf ) =>
236
236
ref match
237
237
case Select (qual1, _) => qual1 =?= qual2
238
238
case ref : Ident =>
@@ -241,7 +241,7 @@ object Matcher {
241
241
case _ => matched
242
242
243
243
/* Match reference */
244
- case (_ : Ref , _ : Ident ) if symbolMatch(scrutinee, pattern) =>
244
+ case (_ : Ref , _ : Ident ) if symbolMatch(scrutinee. asInstanceOf , pattern. asInstanceOf ) =>
245
245
matched
246
246
247
247
/* Match application */
@@ -360,18 +360,25 @@ object Matcher {
360
360
* - The scrutinee has is in the environment and they are equivalent
361
361
* - The scrutinee overrides the symbol of the pattern
362
362
*/
363
- private def symbolMatch (scrutineeTree : Tree , patternTree : Tree )(using Env ): Boolean =
363
+ private def symbolMatch (scrutineeTree : dotc.ast.tpd.Tree , patternTree : dotc.ast.tpd.Tree )(using Env ): Boolean =
364
+ import dotc .ast .tpd .* // TODO remove
364
365
val scrutinee = scrutineeTree.symbol
366
+
367
+ def overridingSymbol (ofclazz : dotc.core.Symbols .Symbol ): dotc.core.Symbols .Symbol =
368
+ if ofclazz.isClass then scrutinee.denot.overridingSymbol(ofclazz.asClass)
369
+ else dotc.core.Symbols .NoSymbol
370
+
365
371
val devirtualizedScrutinee = scrutineeTree match
366
372
case Select (qual, _) =>
367
- val sym = scrutinee. overridingSymbol(qual.tpe.typeSymbol)
373
+ val sym = overridingSymbol(qual.tpe.typeSymbol)
368
374
if sym.exists then sym
369
375
else scrutinee
370
376
case _ => scrutinee
371
377
val pattern = patternTree.symbol
372
378
379
+
373
380
devirtualizedScrutinee == pattern
374
- || summon[Env ].get(devirtualizedScrutinee).contains(pattern)
381
+ || summon[Env ].get(devirtualizedScrutinee. asInstanceOf ).contains(pattern)
375
382
|| devirtualizedScrutinee.allOverriddenSymbols.contains(pattern)
376
383
377
384
private object ClosedPatternTerm {
0 commit comments