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

Perform Matchable check only if type test is needed #16824

Merged
merged 1 commit into from
Feb 3, 2023

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 3, 2023

Fixes #16808

@odersky odersky marked this pull request as ready for review February 3, 2023 11:35
Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, I tested some more on my end.

isInstanceOf can also be used as an escape hatch to make an extractor that does not warn:

object Foo:
  def unapply(a: Any): Option[Int] =
    if a.isInstanceOf[Int] then Some(a.asInstanceOf[Int]) else None
def foo(x: Any) = x match
  case Foo(x) => x + 1

should we be concerned about unapply signatures that refine? (not sure how you could validate that anyway, unapply might not even read the parameter)

@bishabosha bishabosha merged commit f5e6985 into scala:main Feb 3, 2023
@bishabosha bishabosha deleted the fix-16808 branch February 3, 2023 13:02
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
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

Successfully merging this pull request may close these issues.

Pattern-match under "-source future" requires Matchable to check an identical type
3 participants