-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix a Source Break With Function Builders #32893
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 smoke test |
Don't we also need some logic in CSGen to pick up the cached type? Otherwise we'll open a fresh type var disconnected from the rest of the system. Here's a test case that relies on them being connected: protocol P {}
extension String : P {}
@_functionBuilder
struct FooBuilder<T> {}
extension FooBuilder where T : P {
static func buildBlock(_ x: Int, _ y: Int) -> String { "" }
}
func foo<T : P>(@FooBuilder<T> fn: () -> T) {}
foo {
0
0
} |
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.
Thank you!
Before 09db290, the function builder transform used to try to detect when the builder type wasn't fully resolved. In such a case, rather than fail the solution set as we do currently, it would construct a null TypeLoc, then stash the type- variable-laden builder type inside of a TypeExpr and rely on CSGen to reinterpret that as a request to read the stashed type as it was constructing the rest of the system. This used to rely on the ability to construct an implicit TypeExpr node with a null type but now such a thing is banned by the TypeExpr interface. Instead, we have to detect this case and construct an *explicit* TypeExpr node pointing to all the usual fake data. This node's type will be used to resolve the build* member, but the final applied type of the node will be the builder type we stashed earlier - hopefully with outstanding type variables solved. rdar://65116204
@swift-ci smoke test |
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!
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! I think we should get a radar filed to adjust this properly.
@swift-ci smoke test macOS platform |
@swift-ci smoke test Windows |
⛵ |
Before 09db290, the function builder
transform used to try to detect when the builder type wasn't fully
resolved. In such a case, rather than fail the solution set as we do
currently, it would construct a null TypeLoc, then stash the type-
variable-laden builder type inside of a TypeExpr and rely on CSGen
to reinterpret that as a request to read the stashed type as it was
constructing the rest of the system. This used to rely on the ability to construct
an implicit TypeExpr node with a null type but now such a thing is
banned by the TypeExpr interface.
Instead, we have to detect this case and construct an explicit
TypeExpr node pointing to all the usual fake data. This node's type will
be used to resolve the build* member, but the final applied type of the
node will be the builder type we stashed earlier - hopefully with
outstanding type variables solved.
rdar://65116204, SR-13132