-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Reimplement callables using func call.
#24122
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
|
The majority of the diff comes from reverting #24086. |
41eec3d to
1990111
Compare
This reverts commit f7c7edf.
1990111 to
463c4dc
Compare
include/swift/AST/Decl.h
Outdated
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.
Consider adding a IsCallable bit to FuncDecl, instead of checking "callable-ness" on the fly.
That requires further decl/serialization changes - we can make that change after committing our desired func call API.
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.
I'd recommend not doing that, unless this is a particularly hot predicate. Cached bits like this have to be kept in sync with the ast. Also, instead of serializing it, if the bit needs to be stored, it can always be computed in the module reader.
|
@swift-ci Please test tensorflow |
This reverts commit 6466a84.
463c4dc to
ca823b8
Compare
|
@swift-ci Please test tensorflow |
rxwei
left a comment
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! LGTM.
aa1a0c0 to
4734e13
Compare
Remove `call` declarations. Treat methods named `func call` as call-syntax delegate methods.
4734e13 to
4382b73
Compare
|
@swift-ci Please clean test tensorflow |
|
@swift-ci Please clean test tensorflow macOS |
|
We should add tests in combination with other language features such as IUOs and struct CallableStuff {
func call() {}
func call(_ f: () throws -> ()) rethrows {}
}
var x: CallableStuff! = CallableStuff()
x() // should work
x!() // should work
x {} // should work
try x { throw ... } // should work |
Added more tests along those lines in #24157. |
|
Much simpler Dan, great work! |
* Revert "[TF] Introduce callables. (swiftlang#24086)" This reverts commit f7c7edf. * Revert "Fix `call` declaration serialization. (swiftlang#24121)" This reverts commit 6466a84. * Reimplement callables using `func call`. Remove `call` declarations. Treat methods named `func call` as call-syntax delegate methods.
Remove
calldeclarations.Treat methods named
func callas call-syntax delegate methods.