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-13007] provide something like "implements func foo()" to mark a function as implementing a protocol requirement (similar to "override func") #55452

Open
weissi opened this issue Jun 13, 2020 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@weissi
Copy link
Member

weissi commented Jun 13, 2020

Previous ID SR-13007
Radar rdar://problem/64517048
Original Reporter @weissi
Type Bug
Additional Detail from JIRA
Votes 2
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 932d1775b82fde68e3c86848e8289f89

Issue Description:

I'm sure this must be a dupe but I can't find it.

Let's consider this protocol

protocol Foo {
    func foo() -> Void
}

extension Foo {
    func foo() {} // default impl
}

If a user now tries to implement this but gets say the type wrong

struct MyFoo: Foo {
    func foo() -> Int { return 8 }
}

then they won't know they didn't actually implement the protocol's method 🙁.

What I'd like to see is

struct MyFoo: Foo {
    implements func foo() -> Int { return 8 }
}

which would compiler error saying that this method doesn't implement any protocol methods. All in all very similar to override func.

@weissi
Copy link
Member Author

weissi commented Jun 17, 2020

@swift-ci create

@mickeyl
Copy link

mickeyl commented Mar 19, 2021

This is indeed kind of unfortunate and I just lost an hour staring at the screen because I didn't see that some (older) example code for a framework had an abbreviated parameter name in the signature whereas the most recent framework did spell this differently.

With a device such as `implements` this error could have resulted in at least a compiler warning.

@hassila
Copy link

hassila commented Mar 27, 2021

That seems like a very nice addition in line with the override keyword which is very nice.

Perhaps this needs to go through the swift-evolution in practice to happen?

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

3 participants