@@ -128,7 +128,7 @@ object Matcher {
128128
129129 // TODO improve performance
130130
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
132132 private final val debug = false
133133
134134 import qctx .tasty ._
@@ -149,43 +149,35 @@ object Matcher {
149149
150150 def termMatch (scrutineeTerm : Term , patternTerm : Term , hasTypeSplices : Boolean ): Option [Tuple ] = {
151151 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 {
156155 // After matching and doing all subtype checks, we have to approximate all the type bindings
157156 // that we have found and seal them in a quoted.Type
158157 matchings.asOptionOfTuple.map { tup =>
159158 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
161160 case x => x
162161 })
163162 }
164163 }
165- else {
166- scrutineeTerm =?= patternTerm
167- }
168164 }
169165
170166 // TODO factor out common logic with `termMatch`
171167 def typeTreeMatch (scrutineeTypeTree : TypeTree , patternTypeTree : TypeTree , hasTypeSplices : Boolean ): Option [Tuple ] = {
172168 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 {
177172 // After matching and doing all subtype checks, we have to approximate all the type bindings
178173 // that we have found and seal them in a quoted.Type
179174 matchings.asOptionOfTuple.map { tup =>
180175 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
182177 case x => x
183178 })
184179 }
185180 }
186- else {
187- scrutineeTypeTree =?= patternTypeTree
188- }
189181 }
190182
191183 private def hasPatternTypeAnnotation (sym : Symbol ) = sym.annots.exists(isPatternTypeAnnotation)
@@ -326,7 +318,7 @@ object Matcher {
326318 fn1 =?= fn2 &&& args1 =?= args2
327319
328320 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 )
330322 matched(new SymBinding (binding.symbol, hasFromAboveAnnotation(binding.symbol))) &&& Block (stats1, expr1) =?= Block (stats2, expr2)
331323
332324 /* Match block */
@@ -343,7 +335,7 @@ object Matcher {
343335
344336 case (scrutinee, Block (typeBindings, expr2)) if typeBindings.forall(isTypeBinding) =>
345337 val bindingSymbols = typeBindings.map(_.symbol)
346- qctx.tasty.Constraints_add (summon[ Context ])( bindingSymbols)
338+ qctx.tasty.Constraints_add (bindingSymbols)
347339 bindingSymbols.foldRight(scrutinee =?= expr2)((x, acc) => matched(new SymBinding (x, hasFromAboveAnnotation(x))) &&& acc)
348340
349341 /* Match if */
0 commit comments