Skip to content

Enable the sendingArgsAndResults experimental feature #2835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public enum ExperimentalFeature: String, CaseIterable {
case doExpressions
case nonescapableTypes
case trailingComma
case sendingArgsAndResults

/// The name of the feature, which is used in the doc comment.
public var featureName: String {
Expand All @@ -33,8 +32,6 @@ public enum ExperimentalFeature: String, CaseIterable {
return "NonEscableTypes"
case .trailingComma:
return "trailing comma"
case .sendingArgsAndResults:
return "SendingArgsAndResults"
}
}

Expand Down
5 changes: 1 addition & 4 deletions CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,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(._const))
&& !self.at(.keyword(.borrowing))
&& !self.at(.keyword(.consuming))
&& !(experimentalFeatures.contains(.sendingArgsAndResults) && self.at(.keyword(.sending)))
&& !self.at(.keyword(.sending))
{
return true
}
Expand Down
3 changes: 0 additions & 3 deletions Sources/SwiftParser/generated/ExperimentalFeatures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,4 @@ extension Parser.ExperimentalFeatures {

/// Whether to enable the parsing of trailing comma.
public static let trailingComma = Self (rawValue: 1 << 4)

/// Whether to enable the parsing of SendingArgsAndResults.
public static let sendingArgsAndResults = Self (rawValue: 1 << 5)
}
10 changes: 2 additions & 8 deletions Sources/SwiftParser/generated/Parser+TokenSpecSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,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 @@ -935,7 +932,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 @@ -3379,9 +3376,6 @@ extension SimpleTypeSpecifierSyntax {
case _const
case borrowing
case consuming
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case sending

init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
Expand All @@ -3400,7 +3394,7 @@ extension SimpleTypeSpecifierSyntax {
self = .borrowing
case TokenSpec(.consuming):
self = .consuming
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 @@ -203,9 +203,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 @@ -3270,18 +3270,9 @@ 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)) {}")
}

func testMisplacedAttributeInVarDeclWithMultipleBindings() {
Expand Down
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
"""
)
}
}