Skip to content

Commit bc1a469

Browse files
committed
Add experimental flag and keyPathMethodComponent node.
1 parent a84f21d commit bc1a469

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

CodeGeneration/Sources/SyntaxSupport/ExperimentalFeatures.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum ExperimentalFeature: String, CaseIterable {
2222
case valueGenerics
2323
case abiAttribute
2424
case unsafeExpression
25+
case keypathWithMethodMembers
2526

2627
/// The name of the feature as it is written in the compiler's `Features.def` file.
2728
public var featureName: String {
@@ -44,6 +45,8 @@ public enum ExperimentalFeature: String, CaseIterable {
4445
return "ABIAttribute"
4546
case .unsafeExpression:
4647
return "WarnUnsafe"
48+
case .keypathWithMethodMembers:
49+
return "KeypathWithMethodMembers"
4750
}
4851
}
4952

@@ -68,6 +71,8 @@ public enum ExperimentalFeature: String, CaseIterable {
6871
return "@abi attribute"
6972
case .unsafeExpression:
7073
return "'unsafe' expression"
74+
case .keypathWithMethodMembers:
75+
return "keypaths with method members"
7176
}
7277
}
7378

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,10 @@ public let EXPR_NODES: [Node] = [
12091209
name: "property",
12101210
kind: .node(kind: .keyPathPropertyComponent)
12111211
),
1212+
Child(
1213+
name: "method",
1214+
kind: .node(kind: .keyPathMethodComponent)
1215+
),
12121216
Child(
12131217
name: "subscript",
12141218
kind: .node(kind: .keyPathSubscriptComponent)
@@ -1313,6 +1317,35 @@ public let EXPR_NODES: [Node] = [
13131317
]
13141318
),
13151319

1320+
Node(
1321+
kind: .keyPathMethodComponent,
1322+
base: .syntax,
1323+
nameForDiagnostics: "key path method component",
1324+
documentation: "A key path component like `.method()`, `.method(10)`, or `.method(val: 10)`.",
1325+
traits: [
1326+
"Parenthesized"
1327+
],
1328+
children: [
1329+
Child(
1330+
name: "declName",
1331+
kind: .node(kind: .declReferenceExpr)
1332+
),
1333+
Child(
1334+
name: "leftParen",
1335+
kind: .token(choices: [.token(.leftParen)])
1336+
),
1337+
Child(
1338+
name: "arguments",
1339+
kind: .collection(kind: .labeledExprList, collectionElementName: "Argument"),
1340+
nameForDiagnostics: "arguments"
1341+
),
1342+
Child(
1343+
name: "rightParen",
1344+
kind: .token(choices: [.token(.rightParen)])
1345+
),
1346+
]
1347+
),
1348+
13161349
Node(
13171350
kind: .macroExpansionExpr,
13181351
base: .expr,

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
178178
case keyPathOptionalComponent
179179
case keyPathPropertyComponent
180180
case keyPathSubscriptComponent
181+
case keyPathMethodComponent
181182
case labeledExpr
182183
case labeledExprList
183184
case labeledSpecializeArgument

0 commit comments

Comments
 (0)