[SR-2078] Conformance to an @objc protocol by a generic type in an extension crashes the compiler
| Previous ID | SR-2078 |
| Radar | rdar://problem/21216149 |
| Original Reporter | @jadengeller |
| Type | Bug |
Environment
Swift 2.2 and Swift 3 b2; other versions untested, but presumably fail also
Additional Detail from JIRA
| Votes | 1 |
| Component/s | Compiler |
| Labels | Bug, CompilerCrash |
| Assignee | None |
| Priority | Medium |
md5: 11c43ab459a5ddfe3d39d960cac1fdd2
is duplicated by:
- SR-4130 Extensions of generic subclasses of NSObject defined in Swift crash in IRGen
Issue Description:
The following will crash the Swift compiler.
@objc protocol Fooable {}
class Foo<T> {}
extension Foo: Fooable {}
I believe this bug may be related to SR-2146.
The following will crash the compiler.
@objc protocol Fooable {}
protocol Barable: Foible {}
class Foo<T> {}
extension Foo: Barable {}
The following modification, where a redundant conformance to `Fooable` is stated at the declaration of `Foo`, serves as a workaround.
@objc protocol Fooable {}
protocol Barable: Fooable {}
class Foo<T>: Fooable {}
extension Foo: Barable {}
Wrong related bug number?
The problem is that generic types can't get Objective-C categories at the moment, which means extensions can't add protocols or @objc members. These should definitely have proper errors, though.
Oh good catch. I meant SR-2146, though I'm not sure that it's related anymore.
I believe this has been resolved, as the given code produces an error in the Xcode 10 toolchain.
@objc protocol Fooable {}class Foo<T> {}
extension Foo: Fooable {} // Conformance of generic class 'Foo<T>' to @objc protocol 'Fooable' cannot be in an extension