Skip to content

Enable InlineArray type sugar #3125

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -21,7 +21,6 @@ public enum ExperimentalFeature: String, CaseIterable {
case coroutineAccessors
case keypathWithMethodMembers
case oldOwnershipOperatorSpellings
case inlineArrayTypeSugar
case defaultIsolationPerFile

/// The name of the feature as it is written in the compiler's `Features.def` file.
Expand All @@ -43,8 +42,6 @@ public enum ExperimentalFeature: String, CaseIterable {
return "KeypathWithMethodMembers"
case .oldOwnershipOperatorSpellings:
return "OldOwnershipOperatorSpellings"
case .inlineArrayTypeSugar:
return "InlineArrayTypeSugar"
case .defaultIsolationPerFile:
return "DefaultIsolationPerFile"
}
Expand All @@ -69,8 +66,6 @@ public enum ExperimentalFeature: String, CaseIterable {
return "keypaths with method members"
case .oldOwnershipOperatorSpellings:
return "`_move` and `_borrow` as ownership operators"
case .inlineArrayTypeSugar:
return "sugar type for InlineArray"
case .defaultIsolationPerFile:
return "set default actor isolation for a file"
}
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 @@ -313,7 +313,6 @@ public let TYPE_NODES: [Node] = [
Node(
kind: .inlineArrayType,
base: .type,
experimentalFeature: .inlineArrayTypeSugar,
nameForDiagnostics: "inline array type",
documentation: "An inline array type `[3 of Int]`, sugar for `InlineArray<3, Int>`.",
children: [
Expand Down
8 changes: 1 addition & 7 deletions Sources/SwiftParser/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,6 @@ extension Parser {
unexpectedBeforeLSquare: RawUnexpectedNodesSyntax?,
leftSquare: RawTokenSyntax
) -> RawTypeSyntax {
precondition(self.experimentalFeatures.contains(.inlineArrayTypeSugar))

// We allow both values and types here and for the element type for
// better recovery in cases where the user writes e.g '[Int of 3]'.
let count = self.parseGenericArgumentType()
Expand Down Expand Up @@ -876,10 +874,6 @@ extension Parser.Lookahead {
/// Checks whether we can parse the start of an InlineArray type. This does
/// not include the element type.
mutating func canParseStartOfInlineArrayTypeBody() -> Bool {
guard self.experimentalFeatures.contains(.inlineArrayTypeSugar) else {
return false
}

// We must have at least '[<type-or-integer> of', which cannot be any other
// kind of expression or type. We specifically look for both types and
// integers for better recovery in e.g cases where the user writes e.g
Expand Down Expand Up @@ -908,7 +902,7 @@ extension Parser.Lookahead {

mutating func canParseCollectionTypeBody() -> Bool {
// Check to see if we have an InlineArray sugar type.
if self.experimentalFeatures.contains(.inlineArrayTypeSugar) {
do {
var lookahead = self.lookahead()
if lookahead.canParseInlineArrayTypeBody() {
self = lookahead
Expand Down
7 changes: 1 addition & 6 deletions Sources/SwiftParser/generated/ExperimentalFeatures.swift

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

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

2 changes: 0 additions & 2 deletions Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift

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

1 change: 1 addition & 0 deletions Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift

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

2 changes: 0 additions & 2 deletions Sources/SwiftSyntax/generated/SyntaxEnum.swift

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

1 change: 0 additions & 1 deletion Sources/SwiftSyntax/generated/SyntaxKind.swift

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

3 changes: 1 addition & 2 deletions Sources/SwiftSyntax/generated/SyntaxRewriter.swift

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

6 changes: 2 additions & 4 deletions Sources/SwiftSyntax/generated/SyntaxVisitor.swift

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

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

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

1 change: 0 additions & 1 deletion Tests/SwiftParserTest/ExpressionTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ final class ExpressionTypeTests: ParserTestCase {
{ ExprSyntax.parse(from: &$0) },
substructure: IdentifierTypeSyntax(name: .identifier("X")),
substructureAfterMarker: "1️⃣",
experimentalFeatures: [.inlineArrayTypeSugar],
line: line
)
}
Expand Down
4 changes: 0 additions & 4 deletions Tests/SwiftParserTest/TypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,6 @@ final class TypeTests: ParserTestCase {
}

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

func testBasic() {
assertParse(
"[3 of Int]",
Expand Down