Skip to content

Commit 5ed8c75

Browse files
authored
Merge branch 'swiftlang:main' into trivia-piece-comment-value
2 parents 2197103 + 3274aaa commit 5ed8c75

File tree

66 files changed

+2702
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2702
-283
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Order is important. The last matching pattern has the most precedence.
99

1010
# Owner of anything in SwiftSyntax not owned by anyone else.
11-
* @ahoppen @bnbarham
11+
* @ahoppen @bnbarham @hamishknight @rintaro
1212

1313
# Macros
1414
/Sources/SwiftSyntaxMacros @DougGregor

.github/workflows/automerge.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Create PR to merge main into release branch
2+
# In the first period after branching the release branch, we typically want to include many changes from `main` in the release branch. This workflow automatically creates a PR every Monday to merge main into the release branch.
3+
# Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow. To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow
4+
on:
5+
schedule:
6+
- cron: '0 9 * * MON'
7+
workflow_dispatch:
8+
jobs:
9+
create_merge_pr:
10+
name: Create PR to merge main into release branch
11+
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main
12+
with:
13+
base_branch: release/6.2
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-syntax') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork

.github/workflows/publish_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- run: |
27-
if [[ "${{ github.triggering_actor }}" != "ahoppen" ]]; then
27+
if [[ "${{ github.triggering_actor }}" != "bnbarham" ]]; then
2828
echo "${{ github.triggering_actor }} is not allowed to create a release"
2929
exit 1
3030
fi

.github/workflows/pull_request.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: Pull request
22

3+
# PRs created by GitHub Actions don't kick off further actions (https://github.com/peter-evans/create-pull-request/blob/d57e551ebc1a16dee0b8c9ea6d24dba7627a6e35/docs/concepts-guidelines.md#triggering-further-workflow-runs).
4+
# As a workaround, we mark automerge PRs that are created by GitHub actions as draft and trigger the GitHub actions by marking the PR as ready for review. We'd prefer not re-triggering testing on a normal user's PR in this case, but skipping them causes the checks to reset.
35
on:
46
pull_request:
5-
types: [opened, reopened, synchronize]
7+
types: [opened, reopened, synchronize, ready_for_review]
68

79
concurrency:
810
group: ${{ github.workflow }}-${{ github.ref }}

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public let ATTRIBUTE_NODES: [Node] = [
7474
// Special arguments for keyword decl name e.g. 'subscript(_:)', and availability arguments.
7575
kind: .node(kind: .specializeAttributeArgumentList)
7676
),
77+
Child(
78+
name: "specializedArguments",
79+
// Special arguments for generic where clause.
80+
kind: .node(kind: .specializedAttributeArgument)
81+
),
7782
Child(
7883
name: "objCName",
7984
// Special arguments for Objective-C names. e.g. 'methodNameWithArg1:Arg2:'
@@ -122,8 +127,7 @@ public let ATTRIBUTE_NODES: [Node] = [
122127
Child(
123128
name: "abiArguments",
124129
// Special arguments for declaration syntax. e.g. @abi(func abiName() -> Int)
125-
kind: .node(kind: .abiAttributeArguments),
126-
experimentalFeature: .abiAttribute
130+
kind: .node(kind: .abiAttributeArguments)
127131
),
128132
]),
129133
documentation: """
@@ -256,7 +260,6 @@ public let ATTRIBUTE_NODES: [Node] = [
256260
Node(
257261
kind: .abiAttributeArguments,
258262
base: .syntax,
259-
experimentalFeature: .abiAttribute,
260263
nameForDiagnostics: "ABI-providing declaration",
261264
documentation: "The arguments of the '@abi' attribute",
262265
children: [
@@ -719,6 +722,19 @@ public let ATTRIBUTE_NODES: [Node] = [
719722
]
720723
),
721724

725+
Node(
726+
kind: .specializedAttributeArgument,
727+
base: .syntax,
728+
nameForDiagnostics: "argument to '@specialized",
729+
documentation: "The generic where clause for the `@specialized` attribute",
730+
children: [
731+
Child(
732+
name: "genericWhereClause",
733+
kind: .node(kind: .genericWhereClause)
734+
)
735+
]
736+
),
737+
722738
Node(
723739
kind: .specializeTargetFunctionArgument,
724740
base: .syntax,

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,37 @@ public let DECL_NODES: [Node] = [
13071307
]
13081308
),
13091309

1310+
Node(
1311+
kind: .usingDecl,
1312+
base: .decl,
1313+
experimentalFeature: .defaultIsolationPerFile,
1314+
nameForDiagnostics: "using",
1315+
documentation: """
1316+
A `using` declaration, currently used to control actor isolation within the current file.
1317+
1318+
An example of a `using` declaration is
1319+
1320+
```swift
1321+
using @MainActor
1322+
```
1323+
""",
1324+
children: [
1325+
Child(
1326+
name: "usingKeyword",
1327+
kind: .token(choices: [.keyword(.using)]),
1328+
documentation: "The `using` keyword for this declaration."
1329+
),
1330+
Child(
1331+
name: "specifier",
1332+
kind: .nodeChoices(choices: [
1333+
Child(name: "attribute", kind: .node(kind: .attribute)),
1334+
Child(name: "modifier", kind: .token(choices: [.token(.identifier)])),
1335+
]),
1336+
documentation: "The specifier that could be either an attribute or a modifier."
1337+
),
1338+
]
1339+
),
1340+
13101341
Node(
13111342
kind: .inheritedTypeList,
13121343
base: .syntaxCollection,

CodeGeneration/Sources/SyntaxSupport/ExperimentalFeatures.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public enum ExperimentalFeature: String, CaseIterable {
1919
case nonescapableTypes
2020
case trailingComma
2121
case coroutineAccessors
22-
case abiAttribute
2322
case keypathWithMethodMembers
2423
case oldOwnershipOperatorSpellings
2524
case inlineArrayTypeSugar
25+
case defaultIsolationPerFile
2626

2727
/// The name of the feature as it is written in the compiler's `Features.def` file.
2828
public var featureName: String {
@@ -39,14 +39,14 @@ public enum ExperimentalFeature: String, CaseIterable {
3939
return "TrailingComma"
4040
case .coroutineAccessors:
4141
return "CoroutineAccessors"
42-
case .abiAttribute:
43-
return "ABIAttribute"
4442
case .keypathWithMethodMembers:
4543
return "KeypathWithMethodMembers"
4644
case .oldOwnershipOperatorSpellings:
4745
return "OldOwnershipOperatorSpellings"
4846
case .inlineArrayTypeSugar:
4947
return "InlineArrayTypeSugar"
48+
case .defaultIsolationPerFile:
49+
return "DefaultIsolationPerFile"
5050
}
5151
}
5252

@@ -65,14 +65,14 @@ public enum ExperimentalFeature: String, CaseIterable {
6565
return "trailing commas"
6666
case .coroutineAccessors:
6767
return "coroutine accessors"
68-
case .abiAttribute:
69-
return "@abi attribute"
7068
case .keypathWithMethodMembers:
7169
return "keypaths with method members"
7270
case .oldOwnershipOperatorSpellings:
7371
return "`_move` and `_borrow` as ownership operators"
7472
case .inlineArrayTypeSugar:
7573
return "sugar type for InlineArray"
74+
case .defaultIsolationPerFile:
75+
return "set default actor isolation for a file"
7676
}
7777
}
7878

CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public enum Keyword: CaseIterable {
104104
case _PackageDescription
105105
case _read
106106
case _RefCountedObject
107+
case specialized
107108
case _specialize
108109
case _spi_available
109110
case _Trivial
@@ -210,6 +211,7 @@ public enum Keyword: CaseIterable {
210211
case none
211212
case nonisolated
212213
case nonmutating
214+
case nonsending
213215
case objc
214216
case obsoleted
215217
case of
@@ -267,14 +269,14 @@ public enum Keyword: CaseIterable {
267269
case unsafe
268270
case unsafeAddress
269271
case unsafeMutableAddress
272+
case using
270273
case `var`
271274
case visibility
272275
case weak
273276
case `where`
274277
case `while`
275278
case willSet
276279
case wrt
277-
case x
278280
case yield
279281

280282
public var spec: KeywordSpec {
@@ -339,6 +341,8 @@ public enum Keyword: CaseIterable {
339341
return KeywordSpec("_read")
340342
case ._RefCountedObject:
341343
return KeywordSpec("_RefCountedObject")
344+
case .specialized:
345+
return KeywordSpec("specialized")
342346
case ._specialize:
343347
return KeywordSpec("_specialize")
344348
case ._spi_available:
@@ -356,7 +360,7 @@ public enum Keyword: CaseIterable {
356360
case ._version:
357361
return KeywordSpec("_version")
358362
case .abi:
359-
return KeywordSpec("abi", experimentalFeature: .abiAttribute)
363+
return KeywordSpec("abi")
360364
case .accesses:
361365
return KeywordSpec("accesses")
362366
case .actor:
@@ -551,6 +555,8 @@ public enum Keyword: CaseIterable {
551555
return KeywordSpec("nonisolated")
552556
case .nonmutating:
553557
return KeywordSpec("nonmutating")
558+
case .nonsending:
559+
return KeywordSpec("nonsending")
554560
case .objc:
555561
return KeywordSpec("objc")
556562
case .obsoleted:
@@ -665,6 +671,8 @@ public enum Keyword: CaseIterable {
665671
return KeywordSpec("unsafeAddress")
666672
case .unsafeMutableAddress:
667673
return KeywordSpec("unsafeMutableAddress")
674+
case .using:
675+
return KeywordSpec("using")
668676
case .var:
669677
return KeywordSpec("var", isLexerClassified: true)
670678
case .visibility:
@@ -679,8 +687,6 @@ public enum Keyword: CaseIterable {
679687
return KeywordSpec("willSet")
680688
case .wrt:
681689
return KeywordSpec("wrt")
682-
case .x:
683-
return KeywordSpec("x", experimentalFeature: .inlineArrayTypeSugar)
684690
case .yield:
685691
return KeywordSpec("yield")
686692
}

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
210210
case multipleTrailingClosureElementList
211211
case namedOpaqueReturnType
212212
case nilLiteralExpr
213+
case nonisolatedSpecifierArgument
214+
case nonisolatedSpecifierArgumentList
215+
case nonisolatedTypeSpecifier
213216
case objCSelectorPiece
214217
case objCSelectorPieceList
215218
case operatorDecl
@@ -256,6 +259,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
256259
case simpleStringLiteralSegmentList
257260
case someOrAnyType
258261
case sourceFile
262+
case specializedAttributeArgument
259263
case specializeAttributeArgumentList
260264
case specializeAvailabilityArgument
261265
case specializeTargetFunctionArgument
@@ -301,6 +305,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
301305
case unresolvedIsExpr
302306
case unresolvedTernaryExpr
303307
case unsafeExpr
308+
case usingDecl
304309
case valueBindingPattern
305310
case variableDecl
306311
case versionComponent
@@ -451,6 +456,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
451456
case .someOrAnyType: return "constrainedSugarType"
452457
case .simpleTypeSpecifier: return "typeSpecifier"
453458
case .specializeAttributeArgumentList: return "specializeAttributeSpecList"
459+
case .specializedAttributeArgument: return "specializedAttribute"
454460
case .specializeAvailabilityArgument: return "availabilityEntry"
455461
case .specializeTargetFunctionArgument: return "targetFunctionEntry"
456462
case .stringLiteralSegmentList: return "stringLiteralSegments"

CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public let TYPE_NODES: [Node] = [
304304
base: .type,
305305
experimentalFeature: .inlineArrayTypeSugar,
306306
nameForDiagnostics: "inline array type",
307-
documentation: "An inline array type `[3 x Int]`, sugar for `InlineArray<3, Int>`.",
307+
documentation: "An inline array type `[3 of Int]`, sugar for `InlineArray<3, Int>`.",
308308
children: [
309309
Child(
310310
name: "leftSquare",
@@ -317,12 +317,12 @@ public let TYPE_NODES: [Node] = [
317317
documentation: """
318318
The `count` argument for the inline array type.
319319
320-
- Note: In semantically valid Swift code, this is always an integer or a wildcard type, e.g `_` in `[_ x Int]`.
320+
- Note: In semantically valid Swift code, this is always an integer or a wildcard type, e.g `_` in `[_ of Int]`.
321321
"""
322322
),
323323
Child(
324324
name: "separator",
325-
kind: .token(choices: [.keyword(.x)])
325+
kind: .token(choices: [.keyword(.of)])
326326
),
327327
Child(
328328
name: "element",
@@ -676,6 +676,52 @@ public let TYPE_NODES: [Node] = [
676676
]
677677
),
678678

679+
Node(
680+
kind: .nonisolatedSpecifierArgument,
681+
base: .syntax,
682+
nameForDiagnostics: nil,
683+
documentation: """
684+
A single argument that can be added to a nonisolated specifier: 'nonsending'.
685+
686+
### Example
687+
`data` in `func foo(data: nonisolated(nonsending) () async -> Void) -> X`
688+
""",
689+
traits: [
690+
"Parenthesized"
691+
],
692+
children: [
693+
Child(
694+
name: "leftParen",
695+
kind: .token(choices: [.token(.leftParen)])
696+
),
697+
Child(
698+
name: "nonsendingKeyword",
699+
kind: .token(choices: [.keyword(.nonsending)])
700+
),
701+
Child(
702+
name: "rightParen",
703+
kind: .token(choices: [.token(.rightParen)])
704+
),
705+
]
706+
),
707+
708+
Node(
709+
kind: .nonisolatedTypeSpecifier,
710+
base: .syntax,
711+
nameForDiagnostics: "'nonisolated' specifier",
712+
children: [
713+
Child(
714+
name: "nonisolatedKeyword",
715+
kind: .token(choices: [.keyword(.nonisolated)])
716+
),
717+
Child(
718+
name: "argument",
719+
kind: .node(kind: .nonisolatedSpecifierArgument),
720+
isOptional: true
721+
),
722+
]
723+
),
724+
679725
Node(
680726
kind: .simpleTypeSpecifier,
681727
base: .syntax,
@@ -689,7 +735,6 @@ public let TYPE_NODES: [Node] = [
689735
.keyword(.__shared),
690736
.keyword(.__owned),
691737
.keyword(.isolated),
692-
.keyword(.nonisolated),
693738
.keyword(._const),
694739
.keyword(.borrowing),
695740
.keyword(.consuming),
@@ -704,6 +749,6 @@ public let TYPE_NODES: [Node] = [
704749
kind: .typeSpecifierList,
705750
base: .syntaxCollection,
706751
nameForDiagnostics: nil,
707-
elementChoices: [.simpleTypeSpecifier, .lifetimeTypeSpecifier]
752+
elementChoices: [.simpleTypeSpecifier, .lifetimeTypeSpecifier, .nonisolatedTypeSpecifier]
708753
),
709754
]

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,11 @@ class ValidateSyntaxNodes: XCTestCase {
372372
message:
373373
"child 'defaultKeyword' has a single keyword as its only token choice and is followed by a colon. It should thus be named 'defaultLabel'"
374374
),
375-
// 'separator' is more descriptive than 'xKeyword'
375+
// 'separator' is more descriptive than 'ofKeyword'
376376
ValidationFailure(
377377
node: .inlineArrayType,
378-
message: "child 'separator' has a single keyword as its only token choice and should thus be named 'xKeyword'"
378+
message:
379+
"child 'separator' has a single keyword as its only token choice and should thus be named 'ofKeyword'"
379380
),
380381
]
381382
)

0 commit comments

Comments
 (0)