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-11004] Unexpected: protocol cannot be satisfied by a non-final class because it uses Self #53394

Closed
swift-ci opened this issue Jun 24, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11004
Radar None
Original Reporter freak4pc (JIRA User)
Type Bug
Status Resolved
Resolution Invalid

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: da3454fbed45603b85f17ae097f4c547

Issue Description:

Sorry for not finding a more suitable title, but it's a bit hard to describe 🙂

I'm wondering basically, why would the following code not work :

But this somehow does:

One of these seems to be a strange bug - but I'd love a clarification as I might totally be wrong here 🙂

Thanks.

@belkadan
Copy link
Contributor

An assignment for an associated type sets a default, not a requirement. So in the second case, you're specifying that the property returns something with an associated type, and associated type inference will then use the concrete static type "UILabel" instead of the dynamic type "Self". The default is going to be ignored all the time.

P.S. In the future, please prefer pasting code inline instead of taking screenshots. That makes it easier to read on small devices or reproduce a problem locally, and if anyone is using text-to-speech they have a chance to read it!

@swift-ci
Copy link
Collaborator Author

Comment by Shai Mishali (JIRA)

Hey @belkadan- thank you so much for clarifying that, and for your patience.

You're 100% right about the code, I actually wrote it from my phone so I had the screenshots at hand, but will notice next time 🙂

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants