Skip to content

Commit 3894ad3

Browse files
authored
Work around a bug in the older Swift compiler used to build swift-syntax in the toolchain, which affected certain result builder APIs (#541)
This works around a bug which was identified while working towards adding swift-testing to Swift toolchains. See the code comment for a more detailed explanation. ### Modifications: Use a different variant of this swift-syntax API in our macro plugin to avoid the bug. ### Result: Building in the toolchain avoids the failure this was causing. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 50e2907 commit 3894ad3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/TestingMacros/Support/Additions/FunctionDeclSyntaxAdditions.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ extension FunctionParameterSyntax {
142142
// Enclose the base type declaration reference in a 1-element tuple, e.g.
143143
// `(<baseType>)`. It will be used in a member access expression below, and
144144
// some types (such as function types) require this.
145-
let metatypeMemberAccessBase = TupleExprSyntax {
146-
LabeledExprListSyntax {
147-
LabeledExprSyntax(expression: baseTypeDeclReferenceExpr)
148-
}
149-
}
145+
//
146+
// Intentionally avoid using the result builder variant of these APIs due to
147+
// a bug which affected a range of Swift compilers (including the one
148+
// currently used to build swift-syntax in the toolchain) and caused one of
149+
// these APIs to have an incorrect representation in the module interface.
150+
let metatypeMemberAccessBase = TupleExprSyntax(elements: [LabeledExprSyntax(expression: baseTypeDeclReferenceExpr)])
150151

151152
return MemberAccessExprSyntax(base: metatypeMemberAccessBase, name: .identifier("self"))
152153
}

0 commit comments

Comments
 (0)