@@ -253,52 +253,6 @@ object Matcher {
253253 case (TypeApply (fn1, args1), TypeApply (fn2, args2)) =>
254254 fn1 =?= fn2 &&& args1 =?= args2
255255
256- /* Match block */
257- case (Block (stat1 :: stats1, expr1), Block (stat2 :: stats2, expr2)) =>
258- val newEnv = (stat1, stat2) match {
259- case (stat1 : Definition , stat2 : Definition ) =>
260- summon[Env ] + (stat1.symbol.asInstanceOf [dotc.core.Symbols .Symbol ] -> stat2.symbol.asInstanceOf [dotc.core.Symbols .Symbol ])
261- case _ =>
262- summon[Env ]
263- }
264- withEnv(newEnv) {
265- stat1 =?= stat2 &&& Block (stats1, expr1) =?= Block (stats2, expr2)
266- }
267-
268- /* Match if */
269- case (If (cond1, thenp1, elsep1), If (cond2, thenp2, elsep2)) =>
270- cond1 =?= cond2 &&& thenp1 =?= thenp2 &&& elsep1 =?= elsep2
271-
272- /* Match while */
273- case (While (cond1, body1), While (cond2, body2)) =>
274- cond1 =?= cond2 &&& body1 =?= body2
275-
276- /* Match assign */
277- case (Assign (lhs1, rhs1), Assign (lhs2, rhs2)) =>
278- lhs1 =?= lhs2 &&& rhs1 =?= rhs2
279-
280- /* Match new */
281- case (New (tpt1), New (tpt2)) if tpt1.tpe.typeSymbol == tpt2.tpe.typeSymbol =>
282- matched
283-
284- /* Match this */
285- case (This (_), This (_)) if scrutinee.symbol == pattern.symbol =>
286- matched
287-
288- /* Match super */
289- case (Super (qual1, mix1), Super (qual2, mix2)) if mix1 == mix2 =>
290- qual1 =?= qual2
291-
292- /* Match varargs */
293- case (Repeated (elems1, _), Repeated (elems2, _)) if elems1.size == elems2.size =>
294- elems1 =?= elems2
295-
296- /* Match type */
297- // TODO remove this?
298- case (scrutinee : TypeTree , pattern : TypeTree ) if scrutinee.tpe <:< pattern.tpe =>
299- matched
300-
301-
302256 // No Match
303257 case _ =>
304258 otherCases(scrutinee.asInstanceOf , pattern.asInstanceOf )
@@ -317,9 +271,62 @@ object Matcher {
317271 sFlags.is(Lazy ) == pFlags.is(Lazy ) && sFlags.is(Mutable ) == pFlags.is(Mutable )
318272 }
319273
274+ // TODO remove
275+ object TypeTreeTypeTest :
276+ def unapply (x : Tree ): Option [Tree & x.type ] = x match
277+ case x : (tpd.TypeBoundsTree & x.type ) => None
278+ case x : (tpd.Tree & x.type ) if x.isType => Some (x)
279+ case _ => None
280+ end TypeTreeTypeTest
281+
320282 (scrutinee, pattern) match
321283
322- /* Match val */
284+ /* Match block */
285+ case (Block (stat1 :: stats1, expr1), Block (stat2 :: stats2, expr2)) =>
286+ val newEnv = (stat1, stat2) match {
287+ case (stat1 : MemberDef , stat2 : MemberDef ) =>
288+ summon[Env ] + (stat1.symbol -> stat2.symbol)
289+ case _ =>
290+ summon[Env ]
291+ }
292+ withEnv(newEnv) {
293+ stat1 =?= stat2 &&& Block (stats1, expr1) =?= Block (stats2, expr2)
294+ }
295+
296+ /* Match if */
297+ case (If (cond1, thenp1, elsep1), If (cond2, thenp2, elsep2)) =>
298+ cond1 =?= cond2 &&& thenp1 =?= thenp2 &&& elsep1 =?= elsep2
299+
300+ /* Match while */
301+ case (WhileDo (cond1, body1), WhileDo (cond2, body2)) =>
302+ cond1 =?= cond2 &&& body1 =?= body2
303+
304+ /* Match assign */
305+ case (Assign (lhs1, rhs1), Assign (lhs2, rhs2)) =>
306+ lhs1 =?= lhs2 &&& rhs1 =?= rhs2
307+
308+ /* Match new */
309+ case (New (tpt1), New (tpt2)) if tpt1.tpe.typeSymbol == tpt2.tpe.typeSymbol =>
310+ matched
311+
312+ /* Match this */
313+ case (This (_), This (_)) if scrutinee.symbol == pattern.symbol =>
314+ matched
315+
316+ /* Match super */
317+ case (Super (qual1, mix1), Super (qual2, mix2)) if mix1 == mix2 =>
318+ qual1 =?= qual2
319+
320+ /* Match varargs */
321+ case (SeqLiteral (elems1, _), SeqLiteral (elems2, _)) if elems1.size == elems2.size =>
322+ elems1 =?= elems2
323+
324+ /* Match type */
325+ // TODO remove this?
326+ case (TypeTreeTypeTest (scrutinee), TypeTreeTypeTest (pattern)) if scrutinee.tpe <:< pattern.tpe =>
327+ matched
328+
329+ /* Match val */
323330 case (scrutinee @ ValDef (_, tpt1, _), pattern @ ValDef (_, tpt2, _)) if checkValFlags() =>
324331 def rhsEnv = summon[Env ] + (scrutinee.symbol.asInstanceOf [dotc.core.Symbols .Symbol ] -> pattern.symbol.asInstanceOf [dotc.core.Symbols .Symbol ])
325332 tpt1 =?= tpt2 &&& withEnv(rhsEnv)(scrutinee.rhs =?= pattern.rhs)
0 commit comments