Skip to content

Remove ValueGenerics feature from swift-syntax #3022

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 3 commits into from
Apr 1, 2025
Merged
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
@@ -19,7 +19,6 @@ public enum ExperimentalFeature: String, CaseIterable {
case nonescapableTypes
case trailingComma
case coroutineAccessors
case valueGenerics
case abiAttribute
case keypathWithMethodMembers
case oldOwnershipOperatorSpellings
@@ -40,8 +39,6 @@ public enum ExperimentalFeature: String, CaseIterable {
return "TrailingComma"
case .coroutineAccessors:
return "CoroutineAccessors"
case .valueGenerics:
return "ValueGenerics"
case .abiAttribute:
return "ABIAttribute"
case .keypathWithMethodMembers:
@@ -68,8 +65,6 @@ public enum ExperimentalFeature: String, CaseIterable {
return "trailing commas"
case .coroutineAccessors:
return "coroutine accessors"
case .valueGenerics:
return "value generics"
case .abiAttribute:
return "@abi attribute"
case .keypathWithMethodMembers:
6 changes: 2 additions & 4 deletions CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift
Original file line number Diff line number Diff line change
@@ -341,8 +341,7 @@ public let GENERIC_NODES: [Node] = [
),
Child(
name: "expr",
kind: .node(kind: .expr),
experimentalFeature: .valueGenerics
kind: .node(kind: .expr)
),
]),
nameForDiagnostics: "left-hand type",
@@ -362,8 +361,7 @@ public let GENERIC_NODES: [Node] = [
),
Child(
name: "expr",
kind: .node(kind: .expr),
experimentalFeature: .valueGenerics
kind: .node(kind: .expr)
),
]),
nameForDiagnostics: "right-hand type",
3 changes: 1 addition & 2 deletions CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift
Original file line number Diff line number Diff line change
@@ -264,8 +264,7 @@ public let TYPE_NODES: [Node] = [
),
Child(
name: "expr",
kind: .node(kind: .expr),
experimentalFeature: .valueGenerics
kind: .node(kind: .expr)
),
]),
documentation:
6 changes: 0 additions & 6 deletions Sources/SwiftParser/Types.swift
Original file line number Diff line number Diff line change
@@ -1233,12 +1233,6 @@ extension Parser {

extension Parser {
mutating func parseValueType() -> RawExprSyntax? {
// If the 'ValueGenerics' experimental feature hasn't been added, then don't
// attempt to parse values as types.
guard self.experimentalFeatures.contains(.valueGenerics) else {
return nil
}

// Eat any '-' preceding integer literals.
var minusSign: RawTokenSyntax? = nil
if self.atContextualPunctuator("-"),
13 changes: 4 additions & 9 deletions Sources/SwiftParser/generated/ExperimentalFeatures.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Sources/SwiftSyntax/generated/raw/RawSyntaxNodesGHI.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions Sources/SwiftSyntax/generated/raw/RawSyntaxNodesQRS.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesGHI.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesQRS.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/SwiftParserTest/ExpressionTypeTests.swift
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ final class ExpressionTypeTests: ParserTestCase {
{ ExprSyntax.parse(from: &$0) },
substructure: IdentifierTypeSyntax(name: .identifier("X")),
substructureAfterMarker: "1️⃣",
experimentalFeatures: [.inlineArrayTypeSugar, .valueGenerics],
experimentalFeatures: [.inlineArrayTypeSugar],
line: line
)
}
2 changes: 1 addition & 1 deletion Tests/SwiftParserTest/TypeTests.swift
Original file line number Diff line number Diff line change
@@ -541,7 +541,7 @@ final class TypeTests: ParserTestCase {

final class InlineArrayTypeTests: ParserTestCase {
override var experimentalFeatures: Parser.ExperimentalFeatures {
[.inlineArrayTypeSugar, .valueGenerics]
[.inlineArrayTypeSugar]
}

func testBasic() {
57 changes: 19 additions & 38 deletions Tests/SwiftParserTest/ValueGenericsTests.swift
Original file line number Diff line number Diff line change
@@ -121,64 +121,55 @@ final class ValueGenericsTests: ParserTestCase {
],
fixedSource: """
let x: <#type#> = 123
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x: Generic<123>
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x: Generic<-123>
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x = Generic<123>.self
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x = Generic<-123>.self
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x = Generic<123, Int>.self
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x = Generic<-123, Int>.self
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x = Generic<Int, 123>.self
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
let x: Generic<Int, -123>.self
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
@@ -193,36 +184,31 @@ final class ValueGenericsTests: ParserTestCase {
],
fixedSource: """
typealias One = <#type#>1
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
extension Vector where N == 123 {}
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
extension Vector where 123 == N {}
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
extension Vector where N == -123 {}
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
"""
extension Vector where -123 == N {}
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
@@ -240,8 +226,7 @@ final class ValueGenericsTests: ParserTestCase {
],
fixedSource: """
extension Vector where N: <#type#> 123 {}
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
@@ -259,8 +244,7 @@ final class ValueGenericsTests: ParserTestCase {
],
fixedSource: """
extension Vector where N: <#type#> -123 {}
""",
experimentalFeatures: .valueGenerics
"""
)

assertParse(
@@ -274,8 +258,7 @@ final class ValueGenericsTests: ParserTestCase {
DiagnosticSpec(
message: "unexpected code ': N' in extension"
),
],
experimentalFeatures: .valueGenerics
]
)

assertParse(
@@ -289,8 +272,7 @@ final class ValueGenericsTests: ParserTestCase {
DiagnosticSpec(
message: "unexpected code ': N' in extension"
),
],
experimentalFeatures: .valueGenerics
]
)

assertParse(
@@ -302,8 +284,7 @@ final class ValueGenericsTests: ParserTestCase {
),
DiagnosticSpec(message: "unexpected code '-1' in tuple type"),
],
fixedSource: "func foo() -> (<#type#>-1) X",
experimentalFeatures: [.valueGenerics]
fixedSource: "func foo() -> (<#type#>-1) X"
)
}
}