-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix #12260: Add underscore to match type syntax #12261
Conversation
465b4a5
to
c4f54e0
Compare
|
12a5437
to
2e73bf2
Compare
I opened #12278 to discuss simplify separately, it's orthogonal to this PR. |
tests/neg/matchtype-seq.check
Outdated
@@ -78,7 +78,7 @@ longer explanation available when compiling with `-explain` | |||
| and cannot be shown to be disjoint from it either. | |||
| Therefore, reduction cannot advance to the remaining case | |||
| | |||
| case _ => String | |||
| case Any => String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those should be _ => String
since that was what's written.
8fed4e7
to
aa7632c
Compare
71a227e
to
15c3aca
Compare
I updated the PR with another attempt, this time parsing |
15c3aca
to
a8a2dad
Compare
What's the status of If I understand correctly, there's three ways to write the same thing: In term-level matches, under (I don't have any firm opinions about this, I'm just asking questions...) |
a8a2dad
to
0efa54e
Compare
Yes, they are 3 equivalant ways to write catch-all patterns for match types. The situation is actually symetrical between term and type level: def foo(x) = x match
case _ =>
case _: Any =>
case _: ? => // Unlike scalac which complains with
// "error: unbound wildcard type",
// Dotty is perfectly fine with this... type Foo[X] = X match
case _ =>
case Any =>
case ? =>
I like |
Previous missed opportunity was to accept I sense a pun on "Casey at the Bat" coming on. "There is no joy in Matchville." |
Those aren't equivalent though: in the match expression it's switching from terms to types, while in match types it's types only. So I feel like we either embrace the symmetry with match expressions and make |
The community build fails without the |
8968cc1
to
0efa54e
Compare
0efa54e
to
9039a77
Compare
0086d12
to
11a18d2
Compare
2bf7ac8
to
f9ae286
Compare
rebased |
New issue that would be fixed by this: #13855 |
This is a hack to tell `case _ =>` and `case Any =>` apart while printing match type error messages. At this point in the compilation pipeline both `pat` types =:= Any, however because of the slight difference in representation we are able to restore the original syntax. Here is what `pat.toString` gives in each case: // case _ => (TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)) // case Any => (TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Any)) The second case doesn't `eq defn.AnyType` because it starts from <root>, and thus doesn't match the pattern added in this commit.
f9ae286
to
bb96d95
Compare
The warning was removed in scala#12261
The warning was removed in scala#12261 Fixes scala#14332
The warning was removed in scala#12261 Fixes scala#14332
Also subsumes #9172 by fixing #9171.