consider reversing the meaning of `hasClassConstraint`

#62 · open · 0 comments

View on GitHub ↗

mayoff

The `hasClassConstraint` property of `ProtocolDescriptor.Flags` returns `true` if the corresponding bit is **set** in the protocol descriptor. However, when the bit is set, it means that the protocol is **not** class-constrained. Here's how `GenMeta.cpp` sets the bit: ```c++ flags.setClassConstraint(Proto->requiresClass() ? ProtocolClassConstraint::Class : ProtocolClassConstraint::Any); ``` And here's how `MetadataValues.h` defines `ProtocolClassConstraint`: ```c++ /// Flag that indicates whether an existential type is class-constrained or not. enum class ProtocolClassConstraint : bool { /// The protocol is class-constrained, so only class types can conform to it. /// /// This must be 0 for ABI compatibility with Objective-C protocol_t records. Class = false, /// Any type can conform to the protocol. Any = true, }; ``` Given this, `hasClassConstraint` would be more meaningful if it returned `true` when the corresponding bit is **not set**.

Comments