Skip to content

Commit 6d150ea

Browse files
committed
Add initial support for _resultDependsOn and _resultDependsOnSelf
1 parent 71afbc1 commit 6d150ea

File tree

13 files changed

+49
-6
lines changed

13 files changed

+49
-6
lines changed

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ public let DECL_NODES: [Node] = [
461461
.keyword(.private),
462462
.keyword(.public),
463463
.keyword(.reasync),
464+
.keyword(._resultDependsOn),
464465
.keyword(.required),
465466
.keyword(.static),
466467
.keyword(.unowned),

CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public enum Keyword: CaseIterable {
112112
case _projectedValueProperty
113113
case _read
114114
case _RefCountedObject
115+
case _resultDependsOn
116+
case _resultDependsOnSelf
115117
case _semantics
116118
case _specialize
117119
case _spi
@@ -356,6 +358,10 @@ public enum Keyword: CaseIterable {
356358
return KeywordSpec("_read")
357359
case ._RefCountedObject:
358360
return KeywordSpec("_RefCountedObject")
361+
case ._resultDependsOn:
362+
return KeywordSpec("_resultDependsOn")
363+
case ._resultDependsOnSelf:
364+
return KeywordSpec("_resultDependsOnSelf")
359365
case ._semantics:
360366
return KeywordSpec("_semantics")
361367
case ._specialize:

CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public let TYPE_NODES: [Node] = [
5252
.keyword(._const),
5353
.keyword(.borrowing),
5454
.keyword(.consuming),
55+
.keyword(._resultDependsOn),
5556
]),
5657
isOptional: true
5758
),

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension DeclarationModifier {
1818
case .__consuming, .__setter_access, ._const, ._local, .async,
1919
.borrowing, .class, .consuming, .convenience, .distributed, .dynamic,
2020
.final, .indirect, .infix, .isolated, .lazy, .mutating, .nonisolated,
21-
.nonmutating, .optional, .override, .postfix, .prefix, .reasync,
21+
.nonmutating, .optional, .override, .postfix, .prefix, .reasync, ._resultDependsOnSelf,
2222
.required, .rethrows, .static, .weak:
2323
return false
2424
case .fileprivate, .internal, .package, .open, .private,

Sources/SwiftParser/Modifiers.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ extension Parser {
8484
(.declarationModifier(._const), let handle)?,
8585
(.declarationModifier(._local), let handle)?,
8686
(.declarationModifier(.__setter_access), let handle)?,
87-
(.declarationModifier(.reasync), let handle)?:
87+
(.declarationModifier(.reasync), let handle)?,
88+
(.declarationModifier(._resultDependsOnSelf), let handle)?:
8889
let (unexpectedBeforeKeyword, keyword) = self.eat(handle)
8990
elements.append(RawDeclModifierSyntax(unexpectedBeforeKeyword, name: keyword, detail: nil, arena: self.arena))
9091
case (.declarationModifier(.rethrows), _)?:

Sources/SwiftParser/Patterns.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ extension Parser.Lookahead {
354354
&& !self.at(.keyword(.__owned))
355355
&& !self.at(.keyword(.borrowing))
356356
&& !self.at(.keyword(.consuming))
357+
&& !self.at(.keyword(._resultDependsOn))
357358
{
358359
return true
359360
}

Sources/SwiftParser/TokenPrecedence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ enum TokenPrecedence: Comparable {
230230
// Declaration Modifiers
231231
.__consuming, .final, .required, .optional, .lazy, .dynamic, .infix, .postfix, .prefix, .mutating, .nonmutating, .convenience, .override, .package, .open,
232232
.__setter_access, .indirect, .isolated, .nonisolated, .distributed, ._local,
233-
.inout, ._mutating, ._borrow, ._borrowing, .borrowing, ._consuming, .consuming, .consume,
233+
.inout, ._mutating, ._borrow, ._borrowing, .borrowing, ._consuming, .consuming, .consume, ._resultDependsOnSelf, ._resultDependsOn,
234234
// Accessors
235235
.get, .set, .didSet, .willSet, .unsafeAddress, .addressWithOwner, .addressWithNativeOwner, .unsafeMutableAddress,
236236
.mutableAddressWithOwner, .mutableAddressWithNativeOwner, ._read, ._modify,

Sources/SwiftParser/TokenSpecSet.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ enum DeclarationModifier: TokenSpecSet {
376376
case `static`
377377
case unowned
378378
case weak
379+
case _resultDependsOnSelf
379380

380381
init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
381382
switch PrepareForKeywordMatch(lexeme) {
@@ -414,6 +415,7 @@ enum DeclarationModifier: TokenSpecSet {
414415
case TokenSpec(.static): self = .static
415416
case TokenSpec(.unowned): self = .unowned
416417
case TokenSpec(.weak): self = .weak
418+
case TokenSpec(._resultDependsOnSelf): self = ._resultDependsOnSelf
417419
default: return nil
418420
}
419421
}
@@ -455,6 +457,7 @@ enum DeclarationModifier: TokenSpecSet {
455457
case .static: return .keyword(.static)
456458
case .unowned: return TokenSpec(.unowned, recoveryPrecedence: .declKeyword)
457459
case .weak: return TokenSpec(.weak, recoveryPrecedence: .declKeyword)
460+
case ._resultDependsOnSelf: return TokenSpec(._resultDependsOnSelf, recoveryPrecedence: .declKeyword)
458461
}
459462
}
460463
}
@@ -679,6 +682,7 @@ public enum TypeSpecifier: TokenSpecSet {
679682
case shared
680683
case borrowing
681684
case consuming
685+
case _resultDependsOn
682686

683687
init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
684688
switch PrepareForKeywordMatch(lexeme) {
@@ -687,6 +691,7 @@ public enum TypeSpecifier: TokenSpecSet {
687691
case TokenSpec(.__shared): self = .shared
688692
case TokenSpec(.consuming): self = .consuming
689693
case TokenSpec(.borrowing): self = .borrowing
694+
case TokenSpec(._resultDependsOn): self = ._resultDependsOn
690695
default: return nil
691696
}
692697
}
@@ -699,6 +704,7 @@ public enum TypeSpecifier: TokenSpecSet {
699704
case TokenSpec(.__shared): self = .shared
700705
case TokenSpec(.consuming): self = .shared
701706
case TokenSpec(.borrowing): self = .shared
707+
case TokenSpec(._resultDependsOn): self = ._resultDependsOn
702708
default: return nil
703709
}
704710
}
@@ -710,6 +716,7 @@ public enum TypeSpecifier: TokenSpecSet {
710716
case .shared: return .keyword(.__shared)
711717
case .borrowing: return .keyword(.borrowing)
712718
case .consuming: return .keyword(.consuming)
719+
case ._resultDependsOn: return .keyword(._resultDependsOn)
713720
}
714721
}
715722
}

Sources/SwiftParser/generated/Parser+TokenSpecSet.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ extension AttributedTypeSyntax {
183183
case _const
184184
case borrowing
185185
case consuming
186+
case _resultDependsOn
186187

187188
init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
188189
switch PrepareForKeywordMatch(lexeme) {
@@ -200,6 +201,8 @@ extension AttributedTypeSyntax {
200201
self = .borrowing
201202
case TokenSpec(.consuming):
202203
self = .consuming
204+
case TokenSpec(._resultDependsOn):
205+
self = ._resultDependsOn
203206
default:
204207
return nil
205208
}
@@ -221,6 +224,8 @@ extension AttributedTypeSyntax {
221224
return .keyword(.borrowing)
222225
case .consuming:
223226
return .keyword(.consuming)
227+
case ._resultDependsOn:
228+
return .keyword(._resultDependsOn)
224229
}
225230
}
226231

@@ -244,6 +249,8 @@ extension AttributedTypeSyntax {
244249
return .keyword(.borrowing)
245250
case .consuming:
246251
return .keyword(.consuming)
252+
case ._resultDependsOn:
253+
return .keyword(._resultDependsOn)
247254
}
248255
}
249256
}
@@ -714,6 +721,7 @@ extension DeclModifierSyntax {
714721
case `private`
715722
case `public`
716723
case reasync
724+
case _resultDependsOn
717725
case required
718726
case `static`
719727
case unowned
@@ -783,6 +791,8 @@ extension DeclModifierSyntax {
783791
self = .public
784792
case TokenSpec(.reasync):
785793
self = .reasync
794+
case TokenSpec(._resultDependsOn):
795+
self = ._resultDependsOn
786796
case TokenSpec(.required):
787797
self = .required
788798
case TokenSpec(.static):
@@ -860,6 +870,8 @@ extension DeclModifierSyntax {
860870
return .keyword(.public)
861871
case .reasync:
862872
return .keyword(.reasync)
873+
case ._resultDependsOn:
874+
return .keyword(._resultDependsOn)
863875
case .required:
864876
return .keyword(.required)
865877
case .static:
@@ -939,6 +951,8 @@ extension DeclModifierSyntax {
939951
return .keyword(.public)
940952
case .reasync:
941953
return .keyword(.reasync)
954+
case ._resultDependsOn:
955+
return .keyword(._resultDependsOn)
942956
case .required:
943957
return .keyword(.required)
944958
case .static:

Sources/SwiftSyntax/generated/Keyword.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public enum Keyword: UInt8, Hashable {
5454
case _projectedValueProperty
5555
case _read
5656
case _RefCountedObject
57+
case _resultDependsOn
58+
case _resultDependsOnSelf
5759
case _semantics
5860
case _specialize
5961
case _spi
@@ -684,6 +686,8 @@ public enum Keyword: UInt8, Hashable {
684686
switch text {
685687
case "_objcRuntimeName":
686688
self = ._objcRuntimeName
689+
case "_resultDependsOn":
690+
self = ._resultDependsOn
687691
case "addressWithOwner":
688692
self = .addressWithOwner
689693
default:
@@ -722,6 +726,8 @@ public enum Keyword: UInt8, Hashable {
722726
self = ._compilerInitialized
723727
case "_originallyDefinedIn":
724728
self = ._originallyDefinedIn
729+
case "_resultDependsOnSelf":
730+
self = ._resultDependsOnSelf
725731
case "unsafeMutableAddress":
726732
self = .unsafeMutableAddress
727733
default:
@@ -815,6 +821,8 @@ public enum Keyword: UInt8, Hashable {
815821
"_projectedValueProperty",
816822
"_read",
817823
"_RefCountedObject",
824+
"_resultDependsOn",
825+
"_resultDependsOnSelf",
818826
"_semantics",
819827
"_specialize",
820828
"_spi",

Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
388388
.keyword("isolated"),
389389
.keyword("_const"),
390390
.keyword("borrowing"),
391-
.keyword("consuming")
391+
.keyword("consuming"),
392+
.keyword("_resultDependsOn")
392393
]))
393394
assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self))
394395
assertNoError(kind, 3, verify(layout[3], as: RawAttributeListSyntax.self))
@@ -804,6 +805,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
804805
.keyword("private"),
805806
.keyword("public"),
806807
.keyword("reasync"),
808+
.keyword("_resultDependsOn"),
807809
.keyword("required"),
808810
.keyword("static"),
809811
.keyword("unowned"),

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3291,7 +3291,7 @@ public struct AttributeSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxNodePr
32913291

32923292
/// ### Children
32933293
///
3294-
/// - `specifier`: (`inout` | `__shared` | `__owned` | `isolated` | `_const` | `borrowing` | `consuming`)?
3294+
/// - `specifier`: (`inout` | `__shared` | `__owned` | `isolated` | `_const` | `borrowing` | `consuming` | `_resultDependsOn`)?
32953295
/// - `attributes`: ``AttributeListSyntax``
32963296
/// - `baseType`: ``TypeSyntax``
32973297
public struct AttributedTypeSyntax: TypeSyntaxProtocol, SyntaxHashable, _LeafTypeSyntaxNodeProtocol {
@@ -3370,6 +3370,7 @@ public struct AttributedTypeSyntax: TypeSyntaxProtocol, SyntaxHashable, _LeafTyp
33703370
/// - `_const`
33713371
/// - `borrowing`
33723372
/// - `consuming`
3373+
/// - `_resultDependsOn`
33733374
public var specifier: TokenSyntax? {
33743375
get {
33753376
return Syntax(self).child(at: 1)?.cast(TokenSyntax.self)

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesD.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public struct DeclModifierDetailSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyn
169169

170170
/// ### Children
171171
///
172-
/// - `name`: (`__consuming` | `__setter_access` | `_const` | `_local` | `actor` | `async` | `borrowing` | `class` | `consuming` | `convenience` | `distributed` | `dynamic` | `fileprivate` | `final` | `indirect` | `infix` | `internal` | `isolated` | `lazy` | `mutating` | `nonisolated` | `nonmutating` | `open` | `optional` | `override` | `package` | `postfix` | `prefix` | `private` | `public` | `reasync` | `required` | `static` | `unowned` | `weak`)
172+
/// - `name`: (`__consuming` | `__setter_access` | `_const` | `_local` | `actor` | `async` | `borrowing` | `class` | `consuming` | `convenience` | `distributed` | `dynamic` | `fileprivate` | `final` | `indirect` | `infix` | `internal` | `isolated` | `lazy` | `mutating` | `nonisolated` | `nonmutating` | `open` | `optional` | `override` | `package` | `postfix` | `prefix` | `private` | `public` | `reasync` | `_resultDependsOn` | `required` | `static` | `unowned` | `weak`)
173173
/// - `detail`: ``DeclModifierDetailSyntax``?
174174
///
175175
/// ### Contained in
@@ -270,6 +270,7 @@ public struct DeclModifierSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxNod
270270
/// - `private`
271271
/// - `public`
272272
/// - `reasync`
273+
/// - `_resultDependsOn`
273274
/// - `required`
274275
/// - `static`
275276
/// - `unowned`

0 commit comments

Comments
 (0)