Skip to content

Commit 95b9cdc

Browse files
committed
[Typed throws] Add thrown type to effect specifiers
1 parent e8e50f8 commit 95b9cdc

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ public let COMMON_NODES: [Node] = [
7979
]
8080
),
8181

82+
Node(
83+
kind: .thrownType,
84+
base: .syntax,
85+
nameForDiagnostics: "thrown type",
86+
children: [
87+
Child(
88+
name: "leftParen",
89+
kind: .token(choices: [.token(.leftParen)])
90+
),
91+
Child(
92+
name: "type",
93+
kind: .node(kind: .type),
94+
nameForDiagnostics: "type"
95+
),
96+
Child(
97+
name: "rightParen",
98+
kind: .token(choices: [.token(.rightParen)])
99+
),
100+
]
101+
),
102+
82103
Node(
83104
kind: .accessorEffectSpecifiers,
84105
base: .syntax,
@@ -99,6 +120,11 @@ public let COMMON_NODES: [Node] = [
99120
documentation: "The `throws` keyword.",
100121
isOptional: true
101122
),
123+
Child(
124+
name: "thrownType",
125+
kind: .node(kind: .thrownType),
126+
isOptional: true
127+
),
102128
]
103129
),
104130

@@ -122,6 +148,11 @@ public let COMMON_NODES: [Node] = [
122148
documentation: "The `throws` or `rethrows` keyword.",
123149
isOptional: true
124150
),
151+
Child(
152+
name: "thrownType",
153+
kind: .node(kind: .thrownType),
154+
isOptional: true
155+
),
125156
]
126157
),
127158

@@ -324,6 +355,11 @@ public let COMMON_NODES: [Node] = [
324355
kind: .token(choices: [.keyword(.throws)]),
325356
isOptional: true
326357
),
358+
Child(
359+
name: "thrownType",
360+
kind: .node(kind: .thrownType),
361+
isOptional: true
362+
),
327363
]
328364
),
329365

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ public enum SyntaxNodeKind: String, CaseIterable {
268268
case switchExpr
269269
case ternaryExpr
270270
case thenStmt
271+
case thrownType
271272
case throwStmt
272273
case tryExpr
273274
case tupleExpr

CodeGeneration/Sources/SyntaxSupport/Traits.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ public let TRAITS: [Trait] = [
5656
Child(name: "asyncSpecifier", kind: .token(choices: [.keyword(.async), .keyword(.reasync)]), isOptional: true),
5757
Child(name: "unexpectedBetweenAsyncSpecifierAndThrowsSpecifier", kind: .node(kind: .unexpectedNodes), isOptional: true),
5858
Child(name: "throwsSpecifier", kind: .token(choices: [.keyword(.throws), .keyword(.rethrows)]), isOptional: true),
59-
Child(name: "unexpectedAfterThrowsSpecifier", kind: .node(kind: .unexpectedNodes), isOptional: true),
59+
Child(name: "unexpectedBetweenThrowsSpecifierAndThrownType", kind: .node(kind: .unexpectedNodes), isOptional: true),
60+
Child(
61+
name: "thrownType",
62+
kind: .node(kind: .thrownType),
63+
isOptional: true
64+
),
65+
Child(name: "unexpectedAfterThrownType", kind: .node(kind: .unexpectedNodes), isOptional: true),
6066
]
6167
),
6268
Trait(

0 commit comments

Comments
 (0)