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

Add the frozen keyword only to enums with the public or package modifiers #595

Merged
merged 8 commits into from
Jul 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,12 @@ struct TextBasedRenderer: RendererProtocol {

/// Renders the specified enum declaration.
func renderEnum(_ enumDesc: EnumDescription) {
if enumDesc.isFrozen {
func shouldAnnotateAsFrozen(_ enumDesc: EnumDescription) -> Bool {
czechboy0 marked this conversation as resolved.
Show resolved Hide resolved
guard enumDesc.isFrozen else { return false }
guard let accessModifier = enumDesc.accessModifier else { return false }
return accessModifier == .public || accessModifier == .package
}
if shouldAnnotateAsFrozen(enumDesc) {
writer.writeLine("@frozen ")
writer.nextLineAppendsToLastLine()
}
Expand Down