Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider reversing the meaning of hasClassConstraint #62

Open
mayoff opened this issue Aug 2, 2021 · 0 comments
Open

consider reversing the meaning of hasClassConstraint #62

mayoff opened this issue Aug 2, 2021 · 0 comments

Comments

@mayoff
Copy link

mayoff commented Aug 2, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant