Skip to content

Fix #16899 #17068

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

Closed
wants to merge 5 commits into from
Closed

Fix #16899 #17068

wants to merge 5 commits into from

Conversation

Decel
Copy link
Contributor

@Decel Decel commented Mar 8, 2023

Should fix #16899

@@ -151,6 +151,7 @@ object TypeTestsCasts {
// always false test warnings are emitted elsewhere
X.classSymbol.exists && P.classSymbol.exists &&
!X.classSymbol.asClass.mayHaveCommonChild(P.classSymbol.asClass)
|| X.classSymbol.isOneOf(FinalOrSealed)
Copy link
Member

Choose a reason for hiding this comment

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

Option being sealed doesn't mean that isInstanceOf[Option[Int]] isn't unchecked. Except of course that Unset | Option[Int] without sealed Unset means the scrutinee after case 1 is Option[Int], but I don't think we calculate that in type tests cast, and in a way we can't, because the match tree has been transformed. There's three places (that I'm aware of) where we look at the match trees: typing, pattern match translation, and space engine analysis. Perhaps in one of those we can find a way to annotate that the Option[Int] test is fully checked. Even in the case that isn't not the type of the scrutinee, like:

(v: Unset | Option[Int] | List[Long]) match
  case v: Unset =>
  case v: Option[Int] =>
  case v: List[Long] =>

Decel added 2 commits March 15, 2023 01:55
Was fixed in `3.2.1-RC1`. Add a regression test for scala#10369.
@Decel Decel closed this Mar 15, 2023
@Decel Decel reopened this Mar 15, 2023
@Decel Decel closed this Mar 15, 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.

Wrong warning on matching union types
2 participants