Skip to content

consider reversing the meaning of hasClassConstraint #62

@mayoff

Description

@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:

      flags.setClassConstraint(Proto->requiresClass()
                                 ? ProtocolClassConstraint::Class
                                 : ProtocolClassConstraint::Any);

And here's how MetadataValues.h defines ProtocolClassConstraint:

/// 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.

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