-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SE-0096] Implement type(of:) #3878
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
@swift-ci please smoke test. |
|
Cool 👍 Are we keeping compatibility with |
This change is source breaking. It will be compatible until the next patch where I yank support for |
if (Tok.canBeArgumentLabel() && peekToken().is(tok::colon)) { | ||
bool hasOf = Tok.getText() == "of"; | ||
if (!hasOf) { | ||
// User mis-spelled the 'of' label. |
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.
Does this mean it's impossible for user code to define a function named type
(with any argument label)?
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.
It does. It is a limitation of the SE that deserves to be discussed. One solution would be to make this a "magic hash-prefix" function like #selector.
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.
Originally we wanted this function defined in stdlib and not in the parser. But that can't happen for bureaucratic reasons related to protocols and other nominal types having differing expressions allowed after these dynamicType contexts.
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.
Nevertheless, I think I'm going to disable this diagnostic when I do the next patch to properly remove the keyword and make the parser fall back to find user-defined functions.
What's in this pull request?
In the interest of getting this patch in quickly (and because I already have the work done) this patch is going to supersede #3871.
Resolved bug number: (SR-2218)
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
A smoke test on macOS does the following:
device standard libraries are not built.
version of these tests are not run.
A smoke test on Linux does the following:
tests are not run.
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.