Skip to content

Remove resultDependsOn/resultDependsOnSelf #2670

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
Jun 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
1 change: 0 additions & 1 deletion CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ public let DECL_NODES: [Node] = [
.keyword(.private),
.keyword(.public),
.keyword(.reasync),
.keyword(._resultDependsOnSelf),
.keyword(.required),
.keyword(.static),
.keyword(.transferring),
Expand Down
6 changes: 0 additions & 6 deletions CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ public enum Keyword: CaseIterable {
case renamed
case `repeat`
case required
case _resultDependsOn
case _resultDependsOnSelf
case `rethrows`
case retroactive
case `return`
Expand Down Expand Up @@ -643,10 +641,6 @@ public enum Keyword: CaseIterable {
return KeywordSpec("repeat", isLexerClassified: true)
case .required:
return KeywordSpec("required")
case ._resultDependsOn:
return KeywordSpec("_resultDependsOn", experimentalFeature: .nonescapableTypes)
case ._resultDependsOnSelf:
return KeywordSpec("_resultDependsOnSelf", experimentalFeature: .nonescapableTypes)
case .rethrows:
return KeywordSpec("rethrows", isLexerClassified: true)
case .retroactive:
Expand Down
1 change: 0 additions & 1 deletion CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@ public let TYPE_NODES: [Node] = [
.keyword(.borrowing),
.keyword(.consuming),
.keyword(.transferring),
.keyword(._resultDependsOn),
.keyword(.sending),
]),
documentation: "The specifier token that's attached to the type."
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/Declarations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension DeclarationModifier {
case .__consuming, .__setter_access, ._const, ._local, .async,
.borrowing, .class, .consuming, .convenience, .distributed, .dynamic,
.final, .indirect, .infix, .isolated, .lazy, .mutating, .nonmutating,
.optional, .override, .postfix, .prefix, .reasync, ._resultDependsOn, ._resultDependsOnSelf, .required,
.optional, .override, .postfix, .prefix, .reasync, .required,
.rethrows, .static, .weak, .transferring, .sending:
return false
case .fileprivate, .internal, .nonisolated, .package, .open, .private,
Expand Down
3 changes: 1 addition & 2 deletions Sources/SwiftParser/Modifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ extension Parser {
(.declarationModifier(._const), let handle)?,
(.declarationModifier(._local), let handle)?,
(.declarationModifier(.__setter_access), let handle)?,
(.declarationModifier(.reasync), let handle)?,
(.declarationModifier(._resultDependsOnSelf), let handle)?
(.declarationModifier(.reasync), let handle)?
where experimentalFeatures.contains(.nonescapableTypes):
let (unexpectedBeforeKeyword, keyword) = self.eat(handle)
elements.append(RawDeclModifierSyntax(unexpectedBeforeKeyword, name: keyword, detail: nil, arena: self.arena))
Expand Down
1 change: 0 additions & 1 deletion Sources/SwiftParser/Patterns.swift
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ extension Parser.Lookahead {
&& !self.at(.keyword(.consuming))
&& !(experimentalFeatures.contains(.transferringArgsAndResults) && self.at(.keyword(.transferring)))
&& !(experimentalFeatures.contains(.sendingArgsAndResults) && self.at(.keyword(.sending)))
&& !(experimentalFeatures.contains(.nonescapableTypes) && self.at(.keyword(._resultDependsOn)))
{
return true
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/SwiftParser/TokenPrecedence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ enum TokenPrecedence: Comparable {
.__consuming, .final, .required, .optional, .lazy, .dynamic, .infix, .postfix, .prefix, .mutating, .nonmutating,
.convenience, .override, .package, .open,
.__setter_access, .indirect, .isolated, .nonisolated, .distributed, ._local,
.inout, ._mutating, ._borrow, ._borrowing, .borrowing, ._consuming, .consuming, .consume, ._resultDependsOnSelf,
._resultDependsOn,
.inout, ._mutating, ._borrow, ._borrowing, .borrowing, ._consuming, .consuming, .consume,
.transferring, .dependsOn, .scoped, .sending,
// Accessors
.get, .set, .didSet, .willSet, .unsafeAddress, .addressWithOwner, .addressWithNativeOwner, .unsafeMutableAddress,
Expand Down
7 changes: 0 additions & 7 deletions Sources/SwiftParser/TokenSpecSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,6 @@ enum DeclarationModifier: TokenSpecSet {
case transferring
case unowned
case weak
case _resultDependsOn
case _resultDependsOnSelf

init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
switch PrepareForKeywordMatch(lexeme) {
Expand Down Expand Up @@ -424,9 +422,6 @@ enum DeclarationModifier: TokenSpecSet {
case TokenSpec(.sending): self = .sending
case TokenSpec(.unowned): self = .unowned
case TokenSpec(.weak): self = .weak
case TokenSpec(._resultDependsOn) where experimentalFeatures.contains(.nonescapableTypes): self = ._resultDependsOn
case TokenSpec(._resultDependsOnSelf) where experimentalFeatures.contains(.nonescapableTypes):
self = ._resultDependsOnSelf
default: return nil
}
}
Expand Down Expand Up @@ -470,8 +465,6 @@ enum DeclarationModifier: TokenSpecSet {
case .sending: return .keyword(.sending)
case .unowned: return TokenSpec(.unowned, recoveryPrecedence: .declKeyword)
case .weak: return TokenSpec(.weak, recoveryPrecedence: .declKeyword)
case ._resultDependsOn: return TokenSpec(._resultDependsOn, recoveryPrecedence: .declKeyword)
case ._resultDependsOnSelf: return TokenSpec(._resultDependsOnSelf, recoveryPrecedence: .declKeyword)
}
}
}
Expand Down
24 changes: 0 additions & 24 deletions Sources/SwiftParser/generated/Parser+TokenSpecSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,6 @@ extension DeclModifierSyntax {
case `private`
case `public`
case reasync
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _resultDependsOnSelf
case required
case `static`
#if compiler(>=5.8)
Expand Down Expand Up @@ -883,8 +879,6 @@ extension DeclModifierSyntax {
self = .public
case TokenSpec(.reasync):
self = .reasync
case TokenSpec(._resultDependsOnSelf) where experimentalFeatures.contains(.nonescapableTypes):
self = ._resultDependsOnSelf
case TokenSpec(.required):
self = .required
case TokenSpec(.static):
Expand Down Expand Up @@ -966,8 +960,6 @@ extension DeclModifierSyntax {
self = .public
case TokenSpec(.reasync):
self = .reasync
case TokenSpec(._resultDependsOnSelf):
self = ._resultDependsOnSelf
case TokenSpec(.required):
self = .required
case TokenSpec(.static):
Expand Down Expand Up @@ -1049,8 +1041,6 @@ extension DeclModifierSyntax {
return .keyword(.public)
case .reasync:
return .keyword(.reasync)
case ._resultDependsOnSelf:
return .keyword(._resultDependsOnSelf)
case .required:
return .keyword(.required)
case .static:
Expand Down Expand Up @@ -1134,8 +1124,6 @@ extension DeclModifierSyntax {
return .keyword(.public)
case .reasync:
return .keyword(.reasync)
case ._resultDependsOnSelf:
return .keyword(._resultDependsOnSelf)
case .required:
return .keyword(.required)
case .static:
Expand Down Expand Up @@ -3358,10 +3346,6 @@ extension SimpleTypeSpecifierSyntax {
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _resultDependsOn
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case sending

init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
Expand All @@ -3382,8 +3366,6 @@ extension SimpleTypeSpecifierSyntax {
self = .consuming
case TokenSpec(.transferring) where experimentalFeatures.contains(.transferringArgsAndResults):
self = .transferring
case TokenSpec(._resultDependsOn) where experimentalFeatures.contains(.nonescapableTypes):
self = ._resultDependsOn
case TokenSpec(.sending) where experimentalFeatures.contains(.sendingArgsAndResults):
self = .sending
default:
Expand All @@ -3409,8 +3391,6 @@ extension SimpleTypeSpecifierSyntax {
self = .consuming
case TokenSpec(.transferring):
self = .transferring
case TokenSpec(._resultDependsOn):
self = ._resultDependsOn
case TokenSpec(.sending):
self = .sending
default:
Expand All @@ -3436,8 +3416,6 @@ extension SimpleTypeSpecifierSyntax {
return .keyword(.consuming)
case .transferring:
return .keyword(.transferring)
case ._resultDependsOn:
return .keyword(._resultDependsOn)
case .sending:
return .keyword(.sending)
}
Expand Down Expand Up @@ -3465,8 +3443,6 @@ extension SimpleTypeSpecifierSyntax {
return .keyword(.consuming)
case .transferring:
return .keyword(.transferring)
case ._resultDependsOn:
return .keyword(._resultDependsOn)
case .sending:
return .keyword(.sending)
}
Expand Down
14 changes: 0 additions & 14 deletions Sources/SwiftSyntax/generated/Keyword.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,6 @@ public enum Keyword: UInt8, Hashable, Sendable {
case renamed
case `repeat`
case required
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _resultDependsOn
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _resultDependsOnSelf
case `rethrows`
case retroactive
case `return`
Expand Down Expand Up @@ -733,8 +725,6 @@ public enum Keyword: UInt8, Hashable, Sendable {
self = ._objcRuntimeName
case "addressWithOwner":
self = .addressWithOwner
case "_resultDependsOn":
self = ._resultDependsOn
default:
return nil
}
Expand Down Expand Up @@ -771,8 +761,6 @@ public enum Keyword: UInt8, Hashable, Sendable {
self = ._compilerInitialized
case "_originallyDefinedIn":
self = ._originallyDefinedIn
case "_resultDependsOnSelf":
self = ._resultDependsOnSelf
case "unsafeMutableAddress":
self = .unsafeMutableAddress
default:
Expand Down Expand Up @@ -998,8 +986,6 @@ public enum Keyword: UInt8, Hashable, Sendable {
"renamed",
"repeat",
"required",
"_resultDependsOn",
"_resultDependsOnSelf",
"rethrows",
"retroactive",
"return",
Expand Down
2 changes: 0 additions & 2 deletions Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,6 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
.keyword("private"),
.keyword("public"),
.keyword("reasync"),
.keyword("_resultDependsOnSelf"),
.keyword("required"),
.keyword("static"),
.keyword("transferring"),
Expand Down Expand Up @@ -2299,7 +2298,6 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) {
.keyword("borrowing"),
.keyword("consuming"),
.keyword("transferring"),
.keyword("_resultDependsOn"),
.keyword("sending")
]))
assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public struct DeclModifierDetailSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyn

/// ### Children
///
/// - `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` | `_resultDependsOnSelf` | `required` | `static` | `transferring` | `unowned` | `weak` | `sending`)
/// - `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` | `transferring` | `unowned` | `weak` | `sending`)
/// - `detail`: ``DeclModifierDetailSyntax``?
///
/// ### Contained in
Expand Down Expand Up @@ -270,7 +270,6 @@ public struct DeclModifierSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxNod
/// - `private`
/// - `public`
/// - `reasync`
/// - `_resultDependsOnSelf`
/// - `required`
/// - `static`
/// - `transferring`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ public struct SimpleStringLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable,
///
/// ### Children
///
/// - `specifier`: (`inout` | `__shared` | `__owned` | `isolated` | `_const` | `borrowing` | `consuming` | `transferring` | `_resultDependsOn` | `sending`)
/// - `specifier`: (`inout` | `__shared` | `__owned` | `isolated` | `_const` | `borrowing` | `consuming` | `transferring` | `sending`)
///
/// ### Contained in
///
Expand Down Expand Up @@ -1155,7 +1155,6 @@ public struct SimpleTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _LeafSy
/// - `borrowing`
/// - `consuming`
/// - `transferring`
/// - `_resultDependsOn`
/// - `sending`
public var specifier: TokenSyntax {
get {
Expand Down
46 changes: 0 additions & 46 deletions Tests/SwiftParserTest/DeclarationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3225,52 +3225,6 @@ final class DeclarationTests: ParserTestCase {
)
}

func testResultDependsOnSelf() {
assertParse(
"""
class MethodModifiers {
_resultDependsOnSelf func getDependentResult() -> Builtin.NativeObject {
return Builtin.unsafeCastToNativeObject(self)
}
}
""",
experimentalFeatures: .nonescapableTypes
)

assertParse(
"""
class MethodModifiers {
_resultDependsOnSelf func _resultDependsOnSelf() -> Builtin.NativeObject {
return Builtin.unsafeCastToNativeObject(self)
}
}
""",
experimentalFeatures: .nonescapableTypes
)
}

func testResultDependsOn() {
assertParse(
"""
class Klass {}
func testTypeSpecifier(x : _resultDependsOn Klass) -> Builtin.NativeObject {
return Builtin.unsafeCastToNativeObject(x)
}
""",
experimentalFeatures: .nonescapableTypes
)

assertParse(
"""
class Klass {}
func testMultipleTypeSpecifier(x : _resultDependsOn Klass, y : _resultDependsOn Klass) -> (Builtin.NativeObject, Builtin.NativeObject) {
return (Builtin.unsafeCastToNativeObject(x), Builtin.unsafeCastToNativeObject(x))
}
""",
experimentalFeatures: .nonescapableTypes
)
}

func testDeclarationEndingWithNewline() {
let inputs: [UInt: String] = [
#line: "var x = 0\n",
Expand Down