-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
AsyncSequence and protocol conformance rethrows #35224
Conversation
ee587c5
to
91cdb03
Compare
…rethrowing verifies appropriately
…o be based upon throws and not rethrows spelling
This reverts commit d91f1b25b59fff8e4be107c808895ff3f293b394.
… for await in syntax
91cdb03
to
d682168
Compare
@swift-ci build toolchain |
@swift-ci build toolchain |
Linux Toolchain (Ubuntu 16.04) Install command |
macOS Toolchain Install command |
@swift-ci please smoke test |
|
@swift-ci please smoke test macOS |
@swift-ci please 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.
Looks great!
@@ -359,6 +359,10 @@ SIMPLE_DECL_ATTR(rethrows, Rethrows, | |||
RejectByParser | | |||
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove, | |||
57) | |||
SIMPLE_DECL_ATTR(rethrows, AtRethrows, | |||
OnProtocol | | |||
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove, |
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 don't think it's API-stable to remove, is it?
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.
hmm good point, yea this is not API stable to remove.
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.
hmm so the previous annotation btw marks regular rethrows
API stable to remove, isn't that wrong?
|
||
SWIFT_DEBUG_DUMP; | ||
|
||
friend bool operator==(const ProtocolRethrowsRequirementList &lhs, |
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 landed some changes that mean request results no longer have to overload == or hash_value(), so you can remove these if you want
@@ -2981,6 +2981,8 @@ ERROR(override_rethrows_with_non_rethrows,none, | |||
"be 'rethrows'", (bool)) | |||
ERROR(rethrows_without_throwing_parameter,none, | |||
"'rethrows' function must take a throwing function argument", ()) | |||
ERROR(rethrows_attr_on_non_protocol,none, |
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 shouldn't be necessary because you annotated the attribute with OnProtocol in Attrs.def
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.
so that means the other code:
void AttributeChecker::visitAtRethrowsAttr(AtRethrowsAttr *attr) {
if (isa<ProtocolDecl>(D)) {
return;
}
diagnose(attr->getLocation(), diag::rethrows_attr_on_non_protocol);
attr->setInvalid();
}
should change to this?
void AttributeChecker::visitAtRethrowsAttr(AtRethrowsAttr *attr) { }
@@ -4052,6 +4054,8 @@ NOTE(because_rethrows_argument_throws,none, | |||
NOTE(because_rethrows_default_argument_throws,none, | |||
"call is to 'rethrows' function, but a defaulted argument function" | |||
" can throw", ()) | |||
NOTE(because_rethrows_default_conformance_throws,none, | |||
"call is to 'rethrows' function, but a conformance can throw", ()) |
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.
"a conformance has a throwing witness" perhaps?
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.
that will be the first case of witness being used in diagnostics, are we certain that is grok-able enough?
perhaps I can write it as "a conformance has a throwing method satisfying a protocol"?
include/swift/AST/Requirement.h
Outdated
@@ -46,6 +46,7 @@ enum class RequirementKind : unsigned { | |||
// when adding enumerators. | |||
}; | |||
|
|||
|
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.
Unnecessary blank line?
|
||
// only allow rethrowing requirements to be determined from marked protocols | ||
if (!decl->getAttrs().hasAttribute<swift::AtRethrowsAttr>()) { | ||
return ProtocolRethrowsRequirementList(ctx.AllocateCopy(found)); |
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.
Isn't 'found' empty here? You can avoid the call to AllocateCopy and just return an empty ProtocolRethrowsRequirementList
lib/Sema/TypeCheckEffects.cpp
Outdated
|
||
ModuleDecl *getModuleContext() { | ||
assert(getKind() == Kind::Function); | ||
return TheFunction->getModuleContext(); |
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.
Let's always use the DC that we're type checking to get the module instead
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.
hmm that isn't used!, deleting it
} | ||
|
||
static AbstractFunction decomposeFunction(Expr *fn) { | ||
static AbstractFunction decomposeFunction(Expr *fn, ConcreteDeclRef declRef = ConcreteDeclRef()) { |
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.
Nitpick: Line is too long
|
||
public: | ||
explicit AbstractFunction(Kind kind, Expr *fn) | ||
explicit AbstractFunction(Kind kind, Expr *fn, ConcreteDeclRef declRef) |
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 not fish out declRef from fn?
@@ -0,0 +1,78 @@ | |||
// RUN: %target-typecheck-verify-swift | |||
|
|||
@rethrows |
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.
Please add a test for @rethrows on a non-protocol
@swift-ci please smoke test |
@swift-ci please smoke test |
…a valid value and adjust the for-await-in silgen test to reflect the cancel changes
@swift-ci please smoke test |
|
@swift-ci please smoke test |
for @airspeedswift to play around with