@@ -128,7 +128,7 @@ object Matcher {
128
128
129
129
// TODO improve performance
130
130
131
- // TODO use flag from qctx.tasty.rootContext. Maybe -debug or add -debug-macros
131
+ // TODO use flag from qctx.tasty. Maybe -debug or add -debug-macros
132
132
private final val debug = false
133
133
134
134
import qctx .tasty ._
@@ -149,43 +149,35 @@ object Matcher {
149
149
150
150
def termMatch (scrutineeTerm : Term , patternTerm : Term , hasTypeSplices : Boolean ): Option [Tuple ] = {
151
151
given Env = Map .empty
152
- if (hasTypeSplices) {
153
- val ctx : Context = qctx.tasty.Constraints_init (rootContext)
154
- given Context = ctx
155
- val matchings = scrutineeTerm =?= patternTerm
152
+ val matchings = scrutineeTerm =?= patternTerm
153
+ if ! hasTypeSplices then matchings
154
+ else {
156
155
// After matching and doing all subtype checks, we have to approximate all the type bindings
157
156
// that we have found and seal them in a quoted.Type
158
157
matchings.asOptionOfTuple.map { tup =>
159
158
Tuple .fromArray(tup.toArray.map { // TODO improve performance
160
- case x : SymBinding => qctx.tasty.Constraints_approximation (summon[ Context ])( x.sym, ! x.fromAbove).seal
159
+ case x : SymBinding => qctx.tasty.Constraints_approximation (x.sym, ! x.fromAbove).seal
161
160
case x => x
162
161
})
163
162
}
164
163
}
165
- else {
166
- scrutineeTerm =?= patternTerm
167
- }
168
164
}
169
165
170
166
// TODO factor out common logic with `termMatch`
171
167
def typeTreeMatch (scrutineeTypeTree : TypeTree , patternTypeTree : TypeTree , hasTypeSplices : Boolean ): Option [Tuple ] = {
172
168
given Env = Map .empty
173
- if (hasTypeSplices) {
174
- val ctx : Context = qctx.tasty.Constraints_init (rootContext)
175
- given Context = ctx
176
- val matchings = scrutineeTypeTree =?= patternTypeTree
169
+ val matchings = scrutineeTypeTree =?= patternTypeTree
170
+ if ! hasTypeSplices then matchings
171
+ else {
177
172
// After matching and doing all subtype checks, we have to approximate all the type bindings
178
173
// that we have found and seal them in a quoted.Type
179
174
matchings.asOptionOfTuple.map { tup =>
180
175
Tuple .fromArray(tup.toArray.map { // TODO improve performance
181
- case x : SymBinding => qctx.tasty.Constraints_approximation (summon[ Context ])( x.sym, ! x.fromAbove).seal
176
+ case x : SymBinding => qctx.tasty.Constraints_approximation (x.sym, ! x.fromAbove).seal
182
177
case x => x
183
178
})
184
179
}
185
180
}
186
- else {
187
- scrutineeTypeTree =?= patternTypeTree
188
- }
189
181
}
190
182
191
183
private def hasPatternTypeAnnotation (sym : Symbol ) = sym.annots.exists(isPatternTypeAnnotation)
@@ -326,7 +318,7 @@ object Matcher {
326
318
fn1 =?= fn2 &&& args1 =?= args2
327
319
328
320
case (Block (stats1, expr1), Block (binding :: stats2, expr2)) if isTypeBinding(binding) =>
329
- qctx.tasty.Constraints_add (summon[ Context ])( binding.symbol :: Nil )
321
+ qctx.tasty.Constraints_add (binding.symbol :: Nil )
330
322
matched(new SymBinding (binding.symbol, hasFromAboveAnnotation(binding.symbol))) &&& Block (stats1, expr1) =?= Block (stats2, expr2)
331
323
332
324
/* Match block */
@@ -343,7 +335,7 @@ object Matcher {
343
335
344
336
case (scrutinee, Block (typeBindings, expr2)) if typeBindings.forall(isTypeBinding) =>
345
337
val bindingSymbols = typeBindings.map(_.symbol)
346
- qctx.tasty.Constraints_add (summon[ Context ])( bindingSymbols)
338
+ qctx.tasty.Constraints_add (bindingSymbols)
347
339
bindingSymbols.foldRight(scrutinee =?= expr2)((x, acc) => matched(new SymBinding (x, hasFromAboveAnnotation(x))) &&& acc)
348
340
349
341
/* Match if */
0 commit comments