-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SE-0042][AST/Sema/SILGen] Flattening the function type of unapplied method references #3836
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
This patch basically just simplifies the constructors, where in 6 out of 8 cases `isSpecialized = false`
@swift-ci smoke test |
|
||
/// Set whether this function conversion flattens an unapplied member | ||
/// function. | ||
void setFlattening() { |
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.
Might be better to make this its own type of Expr
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.
Thought about this as well, but there's exactly one place where we set this flag …
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.
Right, so that place can make the new Expr type instead. These really are not function conversions...
This is a good start, but I have some issues with the approach. I'd like to see this integrated better with the existing curry thunk stuff. Instead of emitting a curried SILDeclRef and wrapping it in a thunk, it makes more sense to directly emit it at the right uncurry level. |
@@ -360,6 +360,14 @@ class alignas(8) Expr { | |||
< (1 << NumCheckedCastKindBits), | |||
"unable to fit a CheckedCastKind in the given number of bits"); | |||
|
|||
class FunctionConversionExprBitfields { | |||
friend class FunctionConversionExpr; | |||
unsigned : NumExprBits; |
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.
Please use NumImplicitConversionBits here and below.
Reabstraction thunks are now used for this flattening/uncurrying as well. First the self parameter is applied, the variables are updated not to include this first parameter and then the "normal" reabstraction takes place.
Some diagnostics got very bad due to the changes...
->getUncurriedFunction(); | ||
result = coerceToType( | ||
result, newTy, locator.withPathElement(ConstraintLocator::Member)); | ||
cast<FunctionConversionExpr>(result)->setFlattening(); |
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.
Why is the full coerceToType treatment necessary? You're assuming that it will go down one specific path and produce one specific result anyway; just make the FunctionConversionExpr here.
Thank you for your time reviewing this, @slavapestov @rjmccall! |
Can we close this? We will probably go with a different approach for this feature -- we want to retool thunks to have the new uncurried type by default, adding the swift 3 compatibility behavior on top. |
What's in this pull request?
This implements the proposal SE-0042.
With it come a lot of test changes and sadly some regressions in quality of the diagnostics.
Implemented proposal: SE-0042 (SR-1051)
cc @tkremenek
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.