Skip to content

Commit 9d9f46b

Browse files
committed
Mark a number of generated enums as frozen.
Long-term, this isn't what we want, but it avoids a miscompile in older Swift versions (5.5).
1 parent 3164414 commit 9d9f46b

File tree

5 files changed

+6
-0
lines changed

5 files changed

+6
-0
lines changed

Sources/SwiftSyntax/Raw/RawSyntaxNodes.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public struct Raw${node.name}: Raw${node.name if node.is_base() else node.base_t
3939
% enums.append(('Element', [(NODE_MAP[choice_name].swift_syntax_kind, NODE_MAP[choice_name].name) for choice_name in node.collection_element_choices]))
4040
% end
4141
% for (name, choices) in enums:
42+
@frozen
4243
public enum ${name}: RawSyntaxNodeProtocol {
4344
% for (swift_name, type_name) in choices:
4445
case `${swift_name}`(Raw${type_name})

Sources/SwiftSyntax/SyntaxCollections.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public extension SyntaxCollection {
4545
% end
4646
public struct ${node.name}: SyntaxCollection, SyntaxHashable {
4747
% if node.collection_element_choices:
48+
@frozen
4849
public enum Element: SyntaxChildChoices {
4950
% for choice_name in node.collection_element_choices:
5051
% choice = NODE_MAP[choice_name]

Sources/SwiftSyntax/SyntaxEnum.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
//===----------------------------------------------------------------------===//
2121

2222
/// Enum to exhaustively switch over all different syntax nodes.
23+
@frozen
2324
public enum SyntaxEnum {
2425
case unknown(UnknownSyntax)
2526
case token(TokenSyntax)

Sources/SwiftSyntax/SyntaxKind.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//===----------------------------------------------------------------------===//
2020

2121
/// Enumerates the known kinds of Syntax represented in the Syntax tree.
22+
@frozen
2223
public enum SyntaxKind {
2324
case token
2425
case unknown

Sources/SwiftSyntax/TokenKind.swift.gyb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//===----------------------------------------------------------------------===//
1919

2020
/// Enumerates the kinds of tokens in the Swift language.
21+
@frozen
2122
public enum TokenKind: Hashable {
2223
case eof
2324
% for token in SYNTAX_TOKENS:
@@ -143,6 +144,7 @@ extension TokenKind: Equatable {
143144
}
144145

145146
/// Plain token kind value, without an associated `String` value.
147+
@frozen
146148
public enum RawTokenKind: Equatable, Hashable {
147149
case eof
148150
% for token in SYNTAX_TOKENS:

0 commit comments

Comments
 (0)