Skip to content

Commit

Permalink
Enable the sendingArgsAndResults experimental feature
Browse files Browse the repository at this point in the history
- **Explanation**: [SE-0430](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md) was accepted for Swift 6.0 but the corresponding experimental feature `sendingArgsAndResults` in swift-syntax was not enabled with the proposal’s acceptance. Because of this, SwiftParser cannot parse eg. `func whatever(_ foo: sending Foo)`
- **Scope**: Parsing of `sending` parameters in SwiftParser
- **Risk**: Fairly low, this is enabling a feature flag.
- **Testing**: Ran test suite
- **Issue**: #2836 / rdar://135336930
- **Original PR**: #2835
- **Reviewer**: @bnbarham @rintaro @hamishknight
  • Loading branch information
ahoppen committed Sep 5, 2024
1 parent 06b5cdc commit 7aa2516
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 32 deletions.
5 changes: 1 addition & 4 deletions CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,7 @@ public enum Keyword: CaseIterable {
case .throws:
return KeywordSpec("throws", isLexerClassified: true)
case .sending:
return KeywordSpec(
"sending",
experimentalFeature: .sendingArgsAndResults
)
return KeywordSpec("sending")
case .transpose:
return KeywordSpec("transpose")
case .true:
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/Patterns.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ extension Parser.Lookahead {
&& !self.at(.keyword(.__owned))
&& !self.at(.keyword(.borrowing))
&& !self.at(.keyword(.consuming))
&& !(experimentalFeatures.contains(.sendingArgsAndResults) && self.at(.keyword(.sending)))
&& !self.at(.keyword(.sending))
&& !(experimentalFeatures.contains(.nonescapableTypes) && self.at(.keyword(._resultDependsOn)))
{
return true
Expand Down
10 changes: 2 additions & 8 deletions Sources/SwiftParser/generated/Parser+TokenSpecSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,6 @@ extension DeclModifierSyntax {
case `static`
case unowned
case weak
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case sending

init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
Expand Down Expand Up @@ -889,7 +886,7 @@ extension DeclModifierSyntax {
self = .unowned
case TokenSpec(.weak):
self = .weak
case TokenSpec(.sending) where experimentalFeatures.contains(.sendingArgsAndResults):
case TokenSpec(.sending):
self = .sending
default:
return nil
Expand Down Expand Up @@ -3343,9 +3340,6 @@ extension SimpleTypeSpecifierSyntax {
@_spi(ExperimentalLanguageFeatures)
#endif
case _resultDependsOn
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case sending

init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
Expand All @@ -3366,7 +3360,7 @@ extension SimpleTypeSpecifierSyntax {
self = .consuming
case TokenSpec(._resultDependsOn) where experimentalFeatures.contains(.nonescapableTypes):
self = ._resultDependsOn
case TokenSpec(.sending) where experimentalFeatures.contains(.sendingArgsAndResults):
case TokenSpec(.sending):
self = .sending
default:
return nil
Expand Down
3 changes: 0 additions & 3 deletions Sources/SwiftSyntax/generated/Keyword.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ public enum Keyword: UInt8, Hashable, Sendable {
#endif
case scoped
case `self`
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case sending
case `Self`
case Sendable
Expand Down
15 changes: 3 additions & 12 deletions Tests/SwiftParserTest/DeclarationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3295,17 +3295,8 @@ final class DeclarationTests: ParserTestCase {
}

func testSendingTypeSpecifier() {
assertParse(
"func testVarDeclTupleElt() -> (sending String, String) {}",
experimentalFeatures: .sendingArgsAndResults
)
assertParse(
"func testVarDeclTuple2(_ x: (sending String)) {}",
experimentalFeatures: .sendingArgsAndResults
)
assertParse(
"func testVarDeclTuple2(_ x: (sending String, String)) {}",
experimentalFeatures: .sendingArgsAndResults
)
assertParse("func testVarDeclTupleElt() -> (sending String, String) {}")
assertParse("func testVarDeclTuple2(_ x: (sending String)) {}")
assertParse("func testVarDeclTuple2(_ x: (sending String, String)) {}")
}
}
6 changes: 2 additions & 4 deletions Tests/SwiftParserTest/SendingTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ final class SendingTests: ParserTestCase {
"""
class Klass {}
func transferMain(_ x: sending Klass) -> ()
""",
experimentalFeatures: .sendingArgsAndResults
"""
)
}

Expand All @@ -29,8 +28,7 @@ final class SendingTests: ParserTestCase {
"""
class Klass {}
func transferMain(_ y: Klass, _ x: sending Klass, _ z: Klass) -> ()
""",
experimentalFeatures: .sendingArgsAndResults
"""
)
}
}

0 comments on commit 7aa2516

Please sign in to comment.