@@ -145,54 +145,13 @@ object Matcher {
145145
146146 inline private def withEnv [T ](env : Env )(inline body : Env ?=> T ): T = body(using env)
147147
148- class SymBinding (val sym : Symbol , val fromAbove : Boolean )
149-
150- def termMatch (scrutineeTerm : Term , patternTerm : Term , hasTypeSplices : Boolean ): Option [Tuple ] = {
148+ def termMatch (scrutineeTerm : Term , patternTerm : Term ): Option [Tuple ] =
151149 given Env = Map .empty
152- val matchings = scrutineeTerm =?= patternTerm
153- if ! hasTypeSplices then matchings
154- else {
155- // After matching and doing all subtype checks, we have to approximate all the type bindings
156- // that we have found and seal them in a quoted.Type
157- matchings.asOptionOfTuple.map { tup =>
158- Tuple .fromArray(tup.toArray.map { // TODO improve performance
159- case x : SymBinding => qctx.tasty.Constraints_approximation (x.sym, ! x.fromAbove).seal
160- case x => x
161- })
162- }
163- }
164- }
150+ scrutineeTerm =?= patternTerm
165151
166- // TODO factor out common logic with `termMatch`
167- def typeTreeMatch (scrutineeTypeTree : TypeTree , patternTypeTree : TypeTree , hasTypeSplices : Boolean ): Option [Tuple ] = {
152+ def typeTreeMatch (scrutineeTypeTree : TypeTree , patternTypeTree : TypeTree ): Option [Tuple ] =
168153 given Env = Map .empty
169- val matchings = scrutineeTypeTree =?= patternTypeTree
170- if ! hasTypeSplices then matchings
171- else {
172- // After matching and doing all subtype checks, we have to approximate all the type bindings
173- // that we have found and seal them in a quoted.Type
174- matchings.asOptionOfTuple.map { tup =>
175- Tuple .fromArray(tup.toArray.map { // TODO improve performance
176- case x : SymBinding => qctx.tasty.Constraints_approximation (x.sym, ! x.fromAbove).seal
177- case x => x
178- })
179- }
180- }
181- }
182-
183- private def hasPatternTypeAnnotation (sym : Symbol ) = sym.annots.exists(isPatternTypeAnnotation)
184-
185- private def hasFromAboveAnnotation (sym : Symbol ) = sym.annots.exists(isFromAboveAnnotation)
186-
187- private def isPatternTypeAnnotation (tree : Tree ): Boolean = tree match {
188- case New (tpt) => tpt.symbol == qctx.tasty.Definitions_InternalQuotedMatcher_patternTypeAnnot
189- case annot => annot.symbol.owner == qctx.tasty.Definitions_InternalQuotedMatcher_patternTypeAnnot
190- }
191-
192- private def isFromAboveAnnotation (tree : Tree ): Boolean = tree match {
193- case New (tpt) => tpt.symbol == qctx.tasty.Definitions_InternalQuotedMatcher_fromAboveAnnot
194- case annot => annot.symbol.owner == qctx.tasty.Definitions_InternalQuotedMatcher_fromAboveAnnot
195- }
154+ scrutineeTypeTree =?= patternTypeTree
196155
197156 /** Check that all trees match with `mtch` and concatenate the results with &&& */
198157 private def matchLists [T ](l1 : List [T ], l2 : List [T ])(mtch : (T , T ) => Matching ): Matching = (l1, l2) match {
@@ -317,10 +276,6 @@ object Matcher {
317276 case (TypeApply (fn1, args1), TypeApply (fn2, args2)) =>
318277 fn1 =?= fn2 &&& args1 =?= args2
319278
320- case (Block (stats1, expr1), Block (binding :: stats2, expr2)) if isTypeBinding(binding) =>
321- qctx.tasty.Constraints_add (binding.symbol :: Nil )
322- matched(new SymBinding (binding.symbol, hasFromAboveAnnotation(binding.symbol))) &&& Block (stats1, expr1) =?= Block (stats2, expr2)
323-
324279 /* Match block */
325280 case (Block (stat1 :: stats1, expr1), Block (stat2 :: stats2, expr2)) =>
326281 val newEnv = (stat1, stat2) match {
@@ -333,11 +288,6 @@ object Matcher {
333288 stat1 =?= stat2 &&& Block (stats1, expr1) =?= Block (stats2, expr2)
334289 }
335290
336- case (scrutinee, Block (typeBindings, expr2)) if typeBindings.forall(isTypeBinding) =>
337- val bindingSymbols = typeBindings.map(_.symbol)
338- qctx.tasty.Constraints_add (bindingSymbols)
339- bindingSymbols.foldRight(scrutinee =?= expr2)((x, acc) => matched(new SymBinding (x, hasFromAboveAnnotation(x))) &&& acc)
340-
341291 /* Match if */
342292 case (If (cond1, thenp1, elsep1), If (cond2, thenp2, elsep2)) =>
343293 cond1 =?= cond2 &&& thenp1 =?= thenp2 &&& elsep1 =?= elsep2
@@ -456,10 +406,6 @@ object Matcher {
456406 }
457407 }
458408
459- private def isTypeBinding (tree : Tree ): Boolean = tree match {
460- case tree : TypeDef => hasPatternTypeAnnotation(tree.symbol)
461- case _ => false
462- }
463409 }
464410
465411 /** Result of matching a part of an expression */
0 commit comments