@@ -1429,13 +1429,14 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, QuoteUnpickl
1429
1429
end extension
1430
1430
end BindMethodsImpl
1431
1431
1432
- type Unapply = tpd.UnApply
1432
+ type Unapply = tpd.UnApply | tpd. Typed // tpd.Typed containing a tpd.UnApply as expression
1433
1433
1434
1434
object UnapplyTypeTest extends TypeTest [Tree , Unapply ]:
1435
- def unapply (x : Tree ): Option [Unapply & x.type ] = x match
1436
- case x : (tpd.UnApply & x.type ) => Some (x)
1437
- case dotc.ast.Trees .Typed (pattern : tpd.UnApply , _) => Some (pattern.asInstanceOf [Unapply & x.type ]) // FIXME return x
1438
- case _ => None
1435
+ def unapply (x : Tree ): Option [Unapply & x.type ] =
1436
+ x match // keep in sync with UnapplyMethodsImpl.selfUnApply
1437
+ case x : (tpd.UnApply & x.type ) => Some (x)
1438
+ case x : (tpd.Typed & x.type ) if x.expr.isInstanceOf [tpd.UnApply ] => Some (x)
1439
+ case _ => None
1439
1440
end UnapplyTypeTest
1440
1441
1441
1442
object Unapply extends UnapplyModule :
@@ -1447,10 +1448,14 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, QuoteUnpickl
1447
1448
1448
1449
object UnapplyMethodsImpl extends UnapplyMethods :
1449
1450
extension (self : Unapply ):
1450
- def fun : Term = self.fun
1451
- def implicits : List [Term ] = self.implicits
1452
- def patterns : List [Tree ] = effectivePatterns(self.patterns)
1453
- end extension
1451
+ def fun : Term = selfUnApply(self).fun
1452
+ def implicits : List [Term ] = selfUnApply(self).implicits
1453
+ def patterns : List [Tree ] = effectivePatterns(selfUnApply(self).patterns)
1454
+ end extension
1455
+ private def selfUnApply (self : Unapply ): tpd.UnApply =
1456
+ self match // keep in sync with UnapplyTypeTest
1457
+ case self : tpd.UnApply => self
1458
+ case self : tpd.Typed => self.expr.asInstanceOf [tpd.UnApply ]
1454
1459
private def effectivePatterns (patterns : List [Tree ]): List [Tree ] =
1455
1460
patterns match
1456
1461
case patterns0 :+ dotc.ast.Trees .SeqLiteral (elems, _) => patterns0 ::: elems
0 commit comments