Skip to content

Macro type check for protocol failed #15

Description

@miku1958

Hi, I tried to add a macro to convert ObjC's Class (AnyClass in Swift) to the actual type.
miku1958@e9027e4

I've added two functions here that are implemented in ObjC, and I've added them as swift versions in the example
classConforming is to retrieve the class that conform the ObjcProtocol from a dictionary, it return AnyClass
objectConforming is to retrieve the object that conform the ObjcProtocol from a dictionary, it return Any

I can't write a Swift version directly due to compiler limitations, so I'd like to borrow the Macro implementation

The problem happened when I used classConforming and convert the ObjcProtocol to:
classConforming(to: ObjcProtocol.self) as? ObjcProtocol.Type

Compiler give me this error:
Cannot convert value of type '(any ObjcProtocol.Type)?' to type '(any ObjcProtocol).Type?' in coercion

I tried to return another Generic Type or return Any directly but fail, any way I can fix it?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions