Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary deprecation warning for Regex.unapplySeq #9380

Closed
scabug opened this issue Jul 3, 2015 · 3 comments
Closed

Unnecessary deprecation warning for Regex.unapplySeq #9380

scabug opened this issue Jul 3, 2015 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 3, 2015

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
@scabug
Copy link
Author

scabug commented Jul 3, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9380?orig=1
Reporter: @hseeberger
See #6406

@scabug
Copy link
Author

scabug commented Jul 4, 2015

@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.

@scabug
Copy link
Author

scabug commented Mar 12, 2017

@som-snytt said:
scala/scala#5358

@scabug scabug closed this as completed Mar 16, 2017
@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the 2.12.2 milestone Apr 7, 2017
@adriaanm adriaanm modified the milestones: 2.13.0-M1, 2.12.2 Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants