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
A custom extractor that doesn't accept Any but a more specific type can be used in a match expression without any warnings. Example:
scala> object O {
| def unapply(s: String) = Some(1)
| }
defined object O
scala> 1 match {
| case O(n) => n
| case _ => -42
| }
res2: Int = -42
Yet if you use a Regex in a match expression with something that is not string-like, you get a nasty warning:
scala> 1 match {
| case pattern(_) => 0
| case _ => -42
| }
warning: there was one deprecation warning; re-run with -deprecation for details
res1: Int = -42
The text was updated successfully, but these errors were encountered:
@som-snytt said (edited on Aug 24, 2016 11:30:01 PM UTC):
The original issue was to improve type safety. Removing the overload turns the deprecation into an error "error: cannot resolve overloaded unapply". Which is true but obscure.
A custom extractor that doesn't accept
Any
but a more specific type can be used in a match expression without any warnings. Example:Yet if you use a
Regex
in a match expression with something that is not string-like, you get a nasty warning:The text was updated successfully, but these errors were encountered: