Xcode-beta (7A121l): Nested types adhering to generic protocols fails to compile.
| Originator: | owensd | ||
| Number: | rdar://21560283 | Date Originated: | 25-Jun-2015 11:01 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A121l) |
| Classification: | Other Bug | Reproducible: | Always |
I have a TokenizerType defined:
public protocol TokenizerType {
typealias ContentType
typealias ContentIndexType : ForwardIndexType
var rules: [(content: ContentType, offset: ContentIndexType) -> ContentIndexType?] { get }
var content: ContentType { get }
init(content: ContentType)
func next(index: ContentIndexType?) throws -> TokenizerResult<ContentType, ContentIndexType>?
}
It also has an extension to the protocol in that same module for the next() function:
extension TokenizerType where ContentType == String, ContentIndexType == String.Index {
public func next(index: String.Index?) throws -> TokenizerResult<String, String.Index>? { … }
}
Now, when I define a new type, it fails when nested within a function it fails to compile:
func f() {
struct EmptyTokenizer : TokenizerType {
let rules: [(content: String, offset: String.Index) -> String.Index?] = []
let content: String
init(content: String) {
self.content = content
}
func next(index: String.Index?) throws -> TokenizerResult<String, String.Index>? {
return nil
}
}
}
Promoting the struct to global scope works. This seems like a bug.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!