Skip to content

[RemoteInspection] Allow enums to be trivial even with a formal payload #68950

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

Merged

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented Oct 3, 2023

A "trivial" enum is one that carries no information. The previous logic asserted that a trivial enum had only one case and that case had no payload.
But Format below is also a trivial enum:

// Trivial, so zero-sized
enum MyFormatVersion {
  case v4
}
// Also trivial, since the payload carries no information
enum Format {
  case MyFormat(MyFormatVersion)
}

This commit adds a test case similar to the above
and corrects the assertions for trivial enums to
assert that there is either no payload, or that the payload is zero-sized.

Resolves rdar://116406504

A "trivial" enum is one that carries no information.
The previous logic asserted that a trivial enum had only one
case and that case had no payload.
But this is also a trivial payload:
```
// Trivial, so zero-sized
enum MyFormatVersion {
  case v4
}
// Also trivial, since the payload carries no information
enum Format {
  case MyFormat(MyFormatVersion)
}
```

This commit adds a test case similar to the above
and corrects the assertions for trivial enums to
assert that there is either no payload, or that the
payload is zero-sized.

Resolves rdar://116406504
@tbkka tbkka requested review from mikeash and drexin October 3, 2023 21:13
@tbkka
Copy link
Contributor Author

tbkka commented Oct 3, 2023

@swift-ci Please test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's such fun discovering these weird cases.

@tbkka tbkka merged commit 3d8607a into swiftlang:main Oct 4, 2023
@tbkka tbkka deleted the tbkka-rdar116406504-RemoteMirror-voidpayload branch October 4, 2023 14:51
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

Successfully merging this pull request may close these issues.

2 participants