@@ -47,13 +47,15 @@ object Applications {
47
47
ref.info.widenExpr.dealias
48
48
}
49
49
50
+ def canProductMatch (tp : Type )(implicit ctx : Context ) =
51
+ extractorMemberType(tp, nme._1).exists
52
+
50
53
/** Does `tp` fit the "product match" conditions as an unapply result type
51
54
* for a pattern with `numArgs` subpatterns?
52
55
* This is the case of `tp` has members `_1` to `_N` where `N == numArgs`.
53
56
*/
54
57
def isProductMatch (tp : Type , numArgs : Int )(implicit ctx : Context ) =
55
- numArgs > 0 && defn.isProductSubType(tp) &&
56
- productSelectorTypes(tp).size == numArgs
58
+ numArgs > 0 && productArity(tp) == numArgs
57
59
58
60
/** Does `tp` fit the "get match" conditions as an unapply result type?
59
61
* This is the case of `tp` has a `get` member as well as a
@@ -69,7 +71,7 @@ object Applications {
69
71
}
70
72
71
73
def productArity (tp : Type )(implicit ctx : Context ) =
72
- if (defn.isProductSubType (tp)) productSelectorTypes(tp).size else - 1
74
+ if (canProductMatch (tp)) productSelectorTypes(tp).size else - 1
73
75
74
76
def productSelectors (tp : Type )(implicit ctx : Context ): List [Symbol ] = {
75
77
val sels = for (n <- Iterator .from(0 )) yield tp.member(nme.selectorName(n)).symbol
@@ -111,7 +113,7 @@ object Applications {
111
113
getUnapplySelectors(getTp, args, pos)
112
114
else if (unapplyResult isRef defn.BooleanClass )
113
115
Nil
114
- else if (defn.isProductSubType (unapplyResult))
116
+ else if (canProductMatch (unapplyResult))
115
117
productSelectorTypes(unapplyResult)
116
118
// this will cause a "wrong number of arguments in pattern" error later on,
117
119
// which is better than the message in `fail`.
0 commit comments