-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[SE-0293] Extend property wrappers to function and closure parameters #34272
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
4b1430f
to
dbd53bf
Compare
@swift-ci please build toolchain |
@swift-ci please build toolchain macOS platform |
@swift-ci please build toolchain |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
db5aeaf
to
ede2ea8
Compare
@swift-ci please build toolchain |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@swift-ci please build toolchain |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
101fcbc
to
10bcee5
Compare
83fe02f
to
4941843
Compare
@swift-ci please build toolchain |
3 similar comments
@swift-ci please build toolchain |
@swift-ci please build toolchain |
@swift-ci please build toolchain |
@swift-ci please smoke test |
to have a mutating wrappedValue getter.
where the programmer tries to pass a projection argument to a wrapped parameter without 'var projectedValue'.
closure is resolved. This can't be diagnosed earlier because a property wrapper attribute may be inferred in the constraint system.
wrapper projection argument to a wrapped parameter with arguments in the wrapper attribute.
…pper parameters in subscript declarations.
property wrapper in the property wrapper requests.
inference for closure parameters.
position in CSGen. This effectively reverts 6caca26014.
…ressions in PropertyWrapperBackingPropertyInfo.
take in a projected value.
dedicated initializer context for this expressions.
initialization expressions for parameters with attached property wrappers.
around arguments to property wrapper parameters.
generator functions for parameters of public functions.
… use the correct substitution map when emitting the property wrapper generator application in SILGen.
the parameter has an attached property wrapper.
…ppers in protocol requirements.
7f34a8b
to
b3d54b6
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please smoke test |
Build failed |
@swift-ci please smoke test macOS platform |
1 similar comment
@swift-ci please smoke test macOS platform |
auto *functionType = fullFunctionType->getResult()->getAs<FunctionType>(); | ||
functionType = unwrapPropertyWrapperParameterTypes(*this, funcDecl, functionRefKind, | ||
functionType, locator); | ||
openedType = FunctionType::get(fullFunctionType->getParams(), functionType); |
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.
Is there a reason why we're not doing any FunctionType::ExtInfo propagation/preservation here? In other words, are the default ExtInfo flags the goal or do they just happen to work?
And as a general observation that long predates your pull request, it's kind of frustrating that the FunctionType constructor let's one elide (and therefore default) the ExtInfo state. This wouldn't ordinarily be a problem for most constructors but Swift is constantly unpacking and rebuilding function types and I find that the ExtInfo preservation/management to be haphazard. I've been tempted to propose something but I don't know what people think/feel about ExtInfo
.
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.
Ah, I think you're right that dropping them just happens to work here. Thanks for catching - I'll fix this in a followup PR.
Agreed that the default ExtInfo()
makes it too easy to accidentally drop existing ExtInfo when transforming a function type like this. I actually had to fix the same mistake in the body of unwrapPropertyWrapperParameterTypes
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.
Thanks for clarifying. A link to the followup PR would be appreciated. I just posted to the forum about making ExtInfo
preservation/propagation more explicit:
https://forums.swift.org/t/rfc-make-extinfo-param-to-functiontype-construction-always-explicit/45182
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.
Implementation of SE-0293: Extend property wrappers to function and closure parameters.
Approach:
autoclosure
that accepts the wrapped-value or projected-value type, which initializes the property wrapper and calls the underlying function. Other arguments that don't have property wrappers are simply forwarded.buildCurryThunk
. I intend to clean this up.coerceCallArguments
.AppliedPropertyWrapperExpr
is used. When SILGen sees this expression, it will emit an application of the appropriate property wrapper generator function.ParamDecl
). The local computed properties are emitted the same way as local property wrappers - by visiting the "auxiliary decls" during SILGen.A few things that are still a WIP:
throws
,async
)Not implemented in this PR:
$
closure parameters with no attribute)Resolves: rdar://66866426, rdar://71902161