Why can't @objc dynamic applied to property of generic type that is an NSObject?

From what little I understand, generic classes are specialized at compile time.

I wonder then why does this not work:

class Muppet<Color>: NSObject where Color: NSObject {
    @objc dynamic var color: Color?
}

I get the classic Property cannot be marked @objc because its type cannot be represented in Objective-C

IIUC the @objc dynamic ensures that at runtime the correct KVO methods are emitted, but since the variable color is guaranteed to be an Objective-C class, I don't quite understand why this is not possible.

1 Like