You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug
Assignee
None
Priority
Medium
md5: e00f2ec0e30f3d674d9da15f87bdd086
Issue Description:
Marking a protocol with @objc will trick the compiler into thinking that using .self will yield an AnyClass type. The runtime through will determine otherwise and the usage will cause a crash.
i.e.
@objc protocol X {
var answerToEverything: Int { get }
{{}}}
let bundle = Bundle(for: X.self) -> ``Thread 1: EXC_BAD_ACCESS (code=1,..)
Removing the @objc, however, will result in the following compiler error:
Cannot convert value of type 'X.Protocol' to expected argument type 'AnyClass' (aka 'AnyObject.Type')
which actually gives us a hint into the problem: we're supposed to pass in AnyClass, not protocols, structs, enums or any other types.
I can't begin to assume how this should be fixed: by either not allowing the @objc protocol usage at compile time or by extending the API to allow protocols, structs, enums Types, but I am more than happy to listen to other opinions on this matter. Maybe this is more a feature than a bug.
Observation: making the non @objc protocol conform to either the deprecated class or AnyObject still does not make the compiler allow the usage.
The text was updated successfully, but these errors were encountered:
Environment
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
Additional Detail from JIRA
md5: e00f2ec0e30f3d674d9da15f87bdd086
Issue Description:
Marking a protocol with @objc will trick the compiler into thinking that using .self will yield an AnyClass type. The runtime through will determine otherwise and the usage will cause a crash.
i.e.
@objc protocol X {
var answerToEverything: Int { get }
{{}}}
let bundle = Bundle(for: X.self) -> ``Thread 1: EXC_BAD_ACCESS (code=1,..)
Removing the @objc, however, will result in the following compiler error:
Cannot convert value of type 'X.Protocol' to expected argument type 'AnyClass' (aka 'AnyObject.Type')
which actually gives us a hint into the problem: we're supposed to pass in AnyClass, not protocols, structs, enums or any other types.
I can't begin to assume how this should be fixed: by either not allowing the @objc protocol usage at compile time or by extending the API to allow protocols, structs, enums Types, but I am more than happy to listen to other opinions on this matter. Maybe this is more a feature than a bug.
Observation: making the non @objc protocol conform to either the deprecated class or AnyObject still does not make the compiler allow the usage.
The text was updated successfully, but these errors were encountered: