Skip to content

Commit 0ed644b

Browse files
committed
Add experimental flag and keyPathMethodComponent node.
1 parent d8ca62d commit 0ed644b

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,11 @@ 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+
experimentalFeature: .keypathWithMethodMembers
1216+
),
12121217
Child(
12131218
name: "subscript",
12141219
kind: .node(kind: .keyPathSubscriptComponent)
@@ -1313,6 +1318,33 @@ public let EXPR_NODES: [Node] = [
13131318
]
13141319
),
13151320

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

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

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

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,10 @@ class ValidateSyntaxNodes: XCTestCase {
549549
message: "could conform to trait 'Parenthesized' but does not"
550550
),
551551
ValidationFailure(node: .lifetimeTypeSpecifier, message: "could conform to trait 'Parenthesized' but does not"),
552+
ValidationFailure(
553+
node: .keyPathMethodComponent,
554+
message: "could conform to trait 'Parenthesized' but does not"
555+
),
552556
]
553557
)
554558
}

0 commit comments

Comments
 (0)