-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CSDiagnostics] Diagnose invalid partial application #22124
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
Currently supported only partial applications of instance methods marked as `mutating`.
/cc @theblixguy |
@jckarter Since you have worked on this before could you take a look? Any other examples I should add? |
65d18af
to
14f6534
Compare
…al apply Verify that invalid partial apply is detected if base of the mutating method if unknown upfront.
…tics Diagnostics for cases like these has been moved to new diagnostic framework.
14f6534
to
6134533
Compare
@swift-ci please test |
Hopefully our existing test cases cover all the edge cases. One of the tricky ones is partially applying an instance method as a static member:
I think our existing test cases cover this, but it'd be good to confirm. |
@jckarter Yes, existing tests in |
@swift-ci please test source compatibility |
Build failed |
Build failed |
@xedin Also it would be cool to diagnose construction of non-constant metatype values early. Eg if I write
Right now we solve the solution and then diagnose it in MiscDiagnostics. Same with missing
|
@slavapestov I'm preparing the PR for that and another partial application problems like: class A {}
enum B {
func foo() {
bar(A()) // should diagnose as `'A' cannot be passed as 'self' parameter to instance method 'bar' of enum 'B'`
}
func bar(_: A) {}
} I'm just trying to figure out the best way to attach fixes to overload choices. |
Awesome! |
Detect and diagnose invalid partial application of 'mutating' methods and constructor delegation.
This used to be diagnosed by
MiscDiagnostics
when invalid solution is already applied to AST,moving these diagnostics to constraint system allows to detect failures like that early and makes
other diagnostics easier e.g. missing or extraneous metatype base in member reference.