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-358] Compiler crashes when protocol defines a static method and a conforming class implements it non-statically #42978
Comments
Current trunk handles this gracefully: static.swift:13:1: error: type 'TestClass' does not conform to protocol 'TestProtocol'
extension TestClass : TestProtocol { }
^
static.swift:2:17: note: protocol requires function 'foo()' with type '() -> ()'
static func foo()
^
static.swift:6:10: note: candidate operates on an instance, not a type as required
func foo() { |
Comment by Nicolas Ameghino (JIRA) Should I close this ticket? |
Comment by Sophie Parker (JIRA) I have had this same bug triggered by implementing a protocol with class func x() -> Self without protocol extensions. |
Sophie, were you using Xcode's Swift, or one of the snapshots from GitHub? If the former, I think we can call this fixed and close it. |
Comment by Sophie Parker (JIRA) Ah yes that was in Xcode Swift (2.1.1). I've been away so I was unable to download the snapshot and check it there, but given it's the same bug, I agree it should be closed. |
Okay, I've marked it as "resolved". Nicolas, you can close it now, or when you get a chance to test that it's fixed (which could be an Xcode beta). |
Comment by Nicolas Ameghino (JIRA) I'll close it down, test it in next Xcode beta and reopen if needs be, does that sound good? |
Yep, that's fine. Thanks! |
Attachment: Download
Environment
Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)
Target: x86_64-apple-darwin15.2.0
Additional Detail from JIRA
md5: 93f7e814a0d38e6bbdf3321a626f74e7
Issue Description:
Define a protocol that contains a
static
function on it. Then write a protocol extension for said protocol that implements a function of the same name but without thestatic
modifier.When marking a class or struct as conforming to the protocol, the compiler will crash without letting the developer know the cause of the problem.
I ran into this issue by forgetting to add the modifier to the protocol extension. Moreover, the compiler wouldn't tell me that my conforming class wasn't implementing the specified method.
See the attached playground for an example.
If the function in the protocol extension has a different name, the compiler will catch it and let the developer know that the conforming class is missing said function.
Here is the stack trace that Xcode outputs:
The text was updated successfully, but these errors were encountered: