@@ -5,6 +5,7 @@ import scala.annotation.internal.sharable
5
5
import scala .annotation .{Annotation , compileTimeOnly }
6
6
7
7
import dotty .tools .dotc
8
+ import dotty .tools .dotc .ast .tpd
8
9
import dotty .tools .dotc .core .Contexts ._
9
10
import dotty .tools .dotc .core .StdNames .nme
10
11
@@ -99,6 +100,7 @@ import dotty.tools.dotc.core.StdNames.nme
99
100
* ```
100
101
*/
101
102
object Matcher {
103
+ import tpd .*
102
104
103
105
class QuoteMatcher [QCtx <: Quotes & Singleton ](val qctx : QCtx )(using Context ) {
104
106
@@ -117,7 +119,7 @@ object Matcher {
117
119
* ```
118
120
* when matching `a * a` with `x * x` the environment will contain `Map(a -> x)`.
119
121
*/
120
- private type Env = Map [Symbol , Symbol ]
122
+ private type Env = Map [dotc.core. Symbols . Symbol , dotc.core. Symbols . Symbol ]
121
123
122
124
inline private def withEnv [T ](env : Env )(inline body : Env ?=> T ): T = body(using env)
123
125
@@ -202,7 +204,7 @@ object Matcher {
202
204
new TreeMap {
203
205
override def transformTerm (tree : Term )(owner : Symbol ): Term =
204
206
tree match
205
- case tree : Ident => summon[Env ].get(tree.symbol) .flatMap(argsMap.get).getOrElse(tree)
207
+ case tree : Ident => summon[Env ].get(tree.symbol. asInstanceOf ). asInstanceOf [ Option [ Symbol ]] .flatMap(argsMap.get).getOrElse(tree)
206
208
case tree => super .transformTerm(tree)(owner)
207
209
}.transformTree(scrutinee)(Symbol .spliceOwner)
208
210
}
@@ -256,7 +258,7 @@ object Matcher {
256
258
case (Block (stat1 :: stats1, expr1), Block (stat2 :: stats2, expr2)) =>
257
259
val newEnv = (stat1, stat2) match {
258
260
case (stat1 : Definition , stat2 : Definition ) =>
259
- summon[Env ] + (stat1.symbol -> stat2.symbol)
261
+ summon[Env ] + (stat1.symbol. asInstanceOf [dotc.core. Symbols . Symbol ] -> stat2.symbol. asInstanceOf [dotc.core. Symbols . Symbol ] )
260
262
case _ =>
261
263
summon[Env ]
262
264
}
@@ -299,20 +301,20 @@ object Matcher {
299
301
300
302
/* Match val */
301
303
case (ValDef (_, tpt1, rhs1), ValDef (_, tpt2, rhs2)) if checkValFlags() =>
302
- def rhsEnv = summon[Env ] + (scrutinee.symbol -> pattern.symbol)
304
+ def rhsEnv = summon[Env ] + (scrutinee.symbol. asInstanceOf [dotc.core. Symbols . Symbol ] -> pattern.symbol. asInstanceOf [dotc.core. Symbols . Symbol ] )
303
305
tpt1 =?= tpt2 &&& treeOptMatches(rhs1, rhs2)(using rhsEnv)
304
306
305
307
/* Match def */
306
308
case (DefDef (_, paramss1, tpt1, Some (rhs1)), DefDef (_, paramss2, tpt2, Some (rhs2))) =>
307
- def rhsEnv =
308
- val paramSyms : List [(Symbol , Symbol )] =
309
+ def rhsEnv : Env =
310
+ val paramSyms : List [(dotc.core. Symbols . Symbol , dotc.core. Symbols . Symbol )] =
309
311
for
310
312
(clause1, clause2) <- paramss1.zip(paramss2)
311
313
(param1, param2) <- clause1.params.zip(clause2.params)
312
314
yield
313
- param1.symbol -> param2.symbol
315
+ param1.symbol. asInstanceOf [dotc.core. Symbols . Symbol ] -> param2.symbol. asInstanceOf [dotc.core. Symbols . Symbol ]
314
316
val oldEnv : Env = summon[Env ]
315
- val newEnv : List [(Symbol , Symbol )] = (scrutinee.symbol -> pattern.symbol) :: paramSyms
317
+ val newEnv : List [(dotc.core. Symbols . Symbol , dotc.core. Symbols . Symbol )] = (scrutinee.symbol. asInstanceOf [dotc.core. Symbols . Symbol ] -> pattern.symbol. asInstanceOf [dotc.core. Symbols . Symbol ] ) :: paramSyms
316
318
oldEnv ++ newEnv
317
319
318
320
matchLists(paramss1, paramss2)(_ =?= _)
0 commit comments