You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defmsg(usingContext) =i"$tree cannot be used as an extractor in a pattern because it lacks an unapply or unapplySeq method"
2424
+
defmsg(usingContext) =i"$tree cannot be used as an extractor in a pattern because it lacks an ${hl("unapply")} or ${hl("unapplySeq")} method with the appropriate signature"
2425
2425
defexplain(usingContext) =
2426
-
i"""|An ${hl("unapply")} method should be defined in an ${hl("object")} as follow:
2426
+
i"""|An ${hl("unapply")} method should be in an ${hl("object")}, take a single explicit term parameter, and:
2427
2427
| - If it is just a test, return a ${hl("Boolean")}. For example ${hl("case even()")}
2428
2428
| - If it returns a single sub-value of type T, return an ${hl("Option[T]")}
2429
2429
| - If it returns several sub-values T1,...,Tn, group them in an optional tuple ${hl("Option[(T1,...,Tn)]")}
2430
2430
|
2431
+
|Additionnaly, ${hl("unapply")} or ${hl("unapplySeq")} methods can not take type parameters after their explicit term parameter.
2432
+
|
2431
2433
|Sometimes, the number of sub-values isn't fixed and we would like to return a sequence.
2432
2434
|For this reason, you can also define patterns through ${hl("unapplySeq")} which returns ${hl("Option[Seq[T]]")}.
2433
2435
|This mechanism is used for instance in pattern ${hl("case List(x1, ..., xn)")}"""
0 commit comments