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
Remove final in protocol extensions #8010
Remove final in protocol extensions #8010
Conversation
Can you make it a warning in Swift 3 mode and add a testcase to test/Compatibility/? |
It is a warning in Swift 3 and I added |
Oh sorry I missed that you already did that. Looks good, thanks! |
@jrose-apple Does this look ok to you? |
@swift-ci Please smoke test |
I mentioned on the bug (and Joe concurred) that this should still go through swift-evolution, since it's an additional break between Swift 3 and Swift 4. It's tiny but that doesn't automatically mean we should just do it. |
test/attr/attr_final.swift
Outdated
@@ -1,4 +1,4 @@ | |||
// RUN: %target-typecheck-verify-swift | |||
// RUN: %target-typecheck-verify-swift -swift-version 4 |
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 is not a change we should make just yet. We're using our existing test suite as source compatibility tests.
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.
Are you referring to the -swift-version 4
or to the changes to the tests themselves? I thought that all of the source compatibility tests (for v3) were being put int test/Compatibility
. I added -swift-version 4
here in an attempt to follow the pattern I saw in test/attr_[escaping|inlineable|objc]
, but glad to change anything as needed.
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.
-swift-version 4
. You only get to add that if everything in the file is also being tested in Compatibility. (Right, @slavapestov?)
We can certainly put the "cleanup" changes in to remove final where it's not necessary, and we can add the warning unconditionally for now. |
…child decls pass the ASTVerifier
The I also made a PR to foundation(apple/swift-corelibs-foundation#917) to remove the two places where this warning would occur. |
@swift-ci please smoke test |
Thanks, Brian! |
This PR generates an error when the
final
attribute is added to a function or variable inside of a protocol extension. This matches the current semantic model --final
only disables overrides for class types, and it has no effect on protocol extensions. This makesfinal
syntax consistent across struct, enum and protocol types.This PR also cleans up the reporting of the message by adding a fixit, and only reporting the error once in variable declarations with child declarations. For instance, the error message is currently reported multiple times if a final variable declaration has implicit getters and setters.
This error message also uncovered a lot of usage in the test suite, and a few places where
final
was used in extensions of a Error protocols in Foundation.Resolves SR-1762.