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
Add fix-it to error and add note - SR-4637 #8947
Add fix-it to error and add note - SR-4637 #8947
Conversation
@swift-ci please smoke test |
You need commit access to trigger CI. @swift-ci Please smoke test |
@slavapestov Thank you for letting me know. I'll add that to the list of things I learned today :) |
Well, looks like I need to take another look tomorrow. |
You can run tests locally with 'build-script -t', or 'build-script -R -t' to build in release mode, which runs the tests much faster. |
Three failures all for the same reason looks like:
Must have something to do with my call to
I will run all tests locally too. Thank you! UPDATE: I realize now that I failed to run all tests locally before pushing PR. My bad. |
88ec7d5
to
f32969b
Compare
lib/Sema/TypeCheckType.cpp
Outdated
TypeAttributes::getAttrName(i)); | ||
if (attrs.has(TAK_escaping)) { | ||
auto &SM = TC.Context.SourceMgr; | ||
auto loc = attrs.getLoc(TAK_escaping); |
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.
Maybe you can just call attr.getRangeWithAt()?
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 think I would need to call getRangeWithAt()
on an attr
. How do I get the attr
from attrs
?
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.
This entire file is using TypeAttributes
, not DeclAttributes
so the ugly way around is the only way around. It's ripe for refactoring.
lib/Sema/TypeCheckType.cpp
Outdated
@@ -2221,8 +2221,21 @@ Type TypeResolver::resolveAttributedType(TypeAttributes &attrs, | |||
|
|||
for (auto i : FunctionAttrs) { | |||
if (attrs.has(i)) { | |||
TC.diagnose(attrs.getLoc(i), diag::attribute_requires_function_type, | |||
TypeAttributes::getAttrName(i)); | |||
if (attrs.has(TAK_escaping)) { |
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.
Indentation -- we use two space indent
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.
Noted. I use four space for my app projects. Any pro tip for quickly switching back and forth depending on the project?
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.
Xcode has per-project indentation now.
lib/Sema/TypeCheckType.cpp
Outdated
TC.diagnose(repr->getLoc(), diag::escaping_optional_type_argument); | ||
} | ||
} else { | ||
TC.diagnose(attrs.getLoc(i), diag::attribute_requires_function_type, |
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.
Can you unify this with the other case where we emit escaping_optional_type_argument, or extract the logic into a method? That code also has the getAdvancedLoc(-1)... business which could be replaced with getRangeWithAt().
f32969b
to
4e27bbe
Compare
@swift-ci please smoke test |
Success! Thanks @garricn, and welcome to the project. |
Woohoo! Thank you so much for helping @CodaFi . I could not have done it without you. I learned a lot though. My ability to set my workstation with the Swift project, build it, run it, make changes, test the changes, and maintain my copy of the project has certainly increased, so thank you! |
This PR will add a removal fix-it to the ERROR
attribute_requires_function_type
when the@escaping
attribute is applied to a non-function type input parameter.It will also add the NOTE
escaping_optional_type_argument
to the same when the parameter is an optional closure.See: https://twitter.com/garricn/status/854833614487379968
Resolves SR-4637.