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

[SR-15096] Add diagnostic for usage of 'open' extension methods on pure Swift classes #57422

typesanitizer opened this issue Aug 20, 2021 · 1 comment


Copy link

@typesanitizer typesanitizer commented Aug 20, 2021

Previous ID SR-15096
Radar None
Original Reporter @typesanitizer
Type Bug
Status In Progress
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee mininny (JIRA)
Priority Medium

md5: f58fc20f557cce2f2ade639d7c1ce432

Issue Description:

The following code snippet:

public class C { }
extension C {
  open func f() { }

compiles without a diagnostic today. Superficially, it might seem like you can override f from a subclass of C. However, that's not the case; you can only overload it. Being able to override methods declared in extensions would require a mechanism like objc_msgSend, which is why such overloading only works when @objc is present, there is no Swift equivalent for pure Swift classes.

This means that the open is misleading to a reader; we should issue a diagnostic with a fix-it to replace this with public instead in such situations.

Copy link

@swift-ci swift-ci commented Aug 22, 2021

Comment by Minhyuk Kim (JIRA)

Created a PR here! 🙂 #38991

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants