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-11308] Classes should be allowed as extended types with where clauses #53709
Comments
@swift-ci create |
Comment by Owen Voorhees (JIRA) This sounds sort of like https://bugs.swift.org/browse/SR-5260 to me in that if this was allowed, flipping the order would have a slightly different meaning w/ regard to access control. Doesn't seem like a reason to disallow it though. |
owenvoorhees (JIRA User) In my opinion, SR-5260 is more of a distinct feature ("allow protocol compositions in extended types") than this one. We already allow classes in extended types today, only without 'where' clauses. Also, the concern raised there was about Swift 4. I'm not sure if Swift 5 shares the same access control model. |
It does. The only changes to access control between Swift 4 and Swift 5 were patching holes (things that should not have been allowed in Swift 4's model that went undiagnosed). |
cc @slavapestov @DougGregor for opinions. |
(I'm of the opinion that this should be allowed for non-final classes but I also see why it's annoying to implement.) |
Intuitively I can see why this should be allowed to work, however "Self" is not a type parameter that can be constrained in class extensions. I think it would be a fairly big change to make this work. For one, it would change the mangling in all class extensions, since the type of "self" would now be a type parameter and not a class. |
We could limit that to extensions of classes that actually constrain Self, at least, but yeah. |
Additional Detail from JIRA
md5: 0837dece926acd2ecc6ca51c66fcf8ee
Issue Description:
The following code compiles:
but if you flip things around, it stops compiling
with "error: trailing 'where' clause for extension of non-generic type 'C'".
It is not clear whether this is intended behavior or a bug (I think different people have different opinions on this), so I've opened this bug report so we can discuss it in one place.
The text was updated successfully, but these errors were encountered: