-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Sema: Allow collection downcast in cast pattern and remove the diagnostic that it is not implemented #60682
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
Conversation
test/Parse/matching_patterns.swift
Outdated
class Base { } | ||
class Derived : Base { } | ||
|
||
|
||
switch [Derived(), Derived(), Base()] { | ||
case let ds as [Derived]: // expected-error{{collection downcast in cast pattern is not implemented; use an explicit downcast to '[Derived]' instead}} | ||
case let ds as [Derived]: |
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.
Could you please add a test-case that uses switch
+ case let ... as ...
inside of a closure and SILGen test-case for that as well?
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.
Yes, I will address this
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.
@xedin I just pushed new changes. It has more tests!
43cd686
to
02c424c
Compare
02c424c
to
e3e2a57
Compare
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.
Nice!
e3e2a57
to
d7bdf48
Compare
efc15d7
to
7c560d8
Compare
Note: Requesting Slava to review SIL tests. |
test/SILGen/switch.swift
Outdated
// CHECK-LABEL: sil hidden [ossa] @$s6switch30test_isa_pattern_set_downcastt2psyShyxG_tSHRzlF : $@convention(thin) <T where T : Hashable> (@guaranteed Set<T>) -> () { | ||
func test_isa_pattern_set_downcastt<T: Hashable>(ps: Set<T>) { |
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.
Not to commit directly:
// CHECK-LABEL: sil hidden [ossa] @$s6switch30test_isa_pattern_set_downcastt2psyShyxG_tSHRzlF : $@convention(thin) <T where T : Hashable> (@guaranteed Set<T>) -> () { | |
func test_isa_pattern_set_downcastt<T: Hashable>(ps: Set<T>) { | |
// CHECK-LABEL: sil hidden [ossa] @$s6switch29test_isa_pattern_set_downcast2psyShyxG_tSHRzlF : $@convention(thin) <T where T : Hashable> (@guaranteed Set<T>) -> () { | |
func test_isa_pattern_set_downcast<T: Hashable>(ps: Set<T>) { |
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.
fixed that, thanks!
1ef521e
to
968507c
Compare
968507c
to
502a5cd
Compare
@swift-ci please smoke test |
@simanerush The test failure is a false positive, a single-element array literal cannot possibly be heterogeneous. Looks like we need another issue report. The warning will have to be verified in the meantime. |
@slavapestov could you take a look? |
@swift-ci please smoke test macOS |
…stic that it is not implemented
502a5cd
to
3b415f0
Compare
@swift-ci please smoke test |
@swift-ci please clean smoke test macOS |
@swift-ci please smoke test macOS |
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.
Great! There are no functional changes to SIL generation anyway, so let’s land this. We can open a new PR shall Slava have any comments on test matter later on.
@xedin Do you reckon this needs a changelog entry? |
Resolves #56139.