Skip to content
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

Merged
merged 40 commits into from
Jan 26, 2021

Conversation

phausler
Copy link
Contributor

for @airspeedswift to play around with

…o be based upon throws and not rethrows spelling
This reverts commit d91f1b25b59fff8e4be107c808895ff3f293b394.
@phausler
Copy link
Contributor Author

@swift-ci build toolchain

@phausler
Copy link
Contributor Author

@swift-ci build toolchain

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - 7431ec4

Install command
tar zxf swift-PR-35224-519-ubuntu16.04.tar.gz
More info

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - 7431ec4

Install command
tar -zxf swift-PR-35224-820-osx.tar.gz --directory ~/

@phausler
Copy link
Contributor Author

@swift-ci please smoke test

@phausler
Copy link
Contributor Author

10:03:10    '/Users/buildnode/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/buildbot_incremental/ninja-build/ninja' '-C' '/Users/buildnode/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/buildbot_incremental/swift-macosx-x86_64' '-t' 'cleandead'
10:03:10 
10:03:10   failed with:
10:03:10 
10:03:10 
   ninja: error: remove(stdlib/public/Darwin/XCTest/OSX/x86_64): Directory not empty

@phausler
Copy link
Contributor Author

@swift-ci please smoke test macOS

@phausler
Copy link
Contributor Author

@swift-ci please smoke test

@phausler phausler requested review from jckarter and parkera January 15, 2021 22:13
Copy link
Contributor

@slavapestov slavapestov left a 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,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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,
Copy link
Contributor

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

Copy link
Contributor Author

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", ())
Copy link
Contributor

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?

Copy link
Contributor Author

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"?

@@ -46,6 +46,7 @@ enum class RequirementKind : unsigned {
// when adding enumerators.
};


Copy link
Contributor

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));
Copy link
Contributor

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


ModuleDecl *getModuleContext() {
assert(getKind() == Kind::Function);
return TheFunction->getModuleContext();
Copy link
Contributor

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

Copy link
Contributor Author

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()) {
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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

@phausler phausler requested a review from gottesmm January 15, 2021 22:55
@phausler
Copy link
Contributor Author

@swift-ci please smoke test

@phausler
Copy link
Contributor Author

@swift-ci please smoke test

…a valid value and adjust the for-await-in silgen test to reflect the cancel changes
@phausler
Copy link
Contributor Author

@swift-ci please smoke test

@phausler
Copy link
Contributor Author

/utils/gyb_syntax_support/StmtNodes.py:77:89: E501 line too long (89 > 88 characters)

@phausler
Copy link
Contributor Author

@swift-ci please smoke test

@phausler phausler merged commit 6e05240 into swiftlang:main Jan 26, 2021
ahoppen added a commit that referenced this pull request Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants