Skip to content

[Macros] Rework the ExpressionMacro API based on pitch feedback #1104

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 10 commits into from
Dec 3, 2022
Merged
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/Raw/RawSyntaxNodes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct Raw${node.name}: Raw${node.name if node.is_base() else node.base_t
% enums.append(('Element', [(NODE_MAP[choice_name].swift_syntax_kind, NODE_MAP[choice_name].name) for choice_name in node.collection_element_choices]))
% end
% for (name, choices) in enums:
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum ${name}: RawSyntaxNodeProtocol {
% for (swift_name, type_name) in choices:
case `${swift_name}`(Raw${type_name})
Expand Down
48 changes: 24 additions & 24 deletions Sources/SwiftSyntax/Raw/gyb_generated/RawSyntaxNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public struct RawMissingPatternSyntax: RawPatternSyntaxNodeProtocol, RawSyntaxTo

@_spi(RawSyntax)
public struct RawCodeBlockItemSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Item: RawSyntaxNodeProtocol {
case `decl`(RawDeclSyntax)
case `stmt`(RawStmtSyntax)
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public struct RawDictionaryElementListSyntax: RawSyntaxNodeProtocol, RawSyntaxTo

@_spi(RawSyntax)
public struct RawStringLiteralSegmentsSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: RawSyntaxNodeProtocol {
case `stringSegment`(RawStringSegmentSyntax)
case `expressionSegment`(RawExpressionSegmentSyntax)
Expand Down Expand Up @@ -2655,7 +2655,7 @@ public struct RawArrayExprSyntax: RawExprSyntaxNodeProtocol, RawSyntaxToSyntax {

@_spi(RawSyntax)
public struct RawDictionaryExprSyntax: RawExprSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Content: RawSyntaxNodeProtocol {
case `colon`(RawTokenSyntax)
case `elements`(RawDictionaryElementListSyntax)
Expand Down Expand Up @@ -3943,7 +3943,7 @@ public struct RawClosureParamListSyntax: RawSyntaxNodeProtocol, RawSyntaxToSynta

@_spi(RawSyntax)
public struct RawClosureSignatureSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Input: RawSyntaxNodeProtocol {
case `simpleInput`(RawClosureParamListSyntax)
case `input`(RawParameterClauseSyntax)
Expand Down Expand Up @@ -5169,7 +5169,7 @@ public struct RawKeyPathComponentListSyntax: RawSyntaxNodeProtocol, RawSyntaxToS

@_spi(RawSyntax)
public struct RawKeyPathComponentSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Component: RawSyntaxNodeProtocol {
case `property`(RawKeyPathPropertyComponentSyntax)
case `subscript`(RawKeyPathSubscriptComponentSyntax)
Expand Down Expand Up @@ -5458,7 +5458,7 @@ public struct RawKeyPathOptionalComponentSyntax: RawSyntaxNodeProtocol, RawSynta

@_spi(RawSyntax)
public struct RawOldKeyPathExprSyntax: RawExprSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum RootExpr: RawSyntaxNodeProtocol {
case `identifierExpr`(RawIdentifierExprSyntax)
case `specializeExpr`(RawSpecializeExprSyntax)
Expand Down Expand Up @@ -6852,7 +6852,7 @@ public struct RawFunctionSignatureSyntax: RawSyntaxNodeProtocol, RawSyntaxToSynt

@_spi(RawSyntax)
public struct RawIfConfigClauseSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Elements: RawSyntaxNodeProtocol {
case `statements`(RawCodeBlockItemListSyntax)
case `switchCases`(RawSwitchCaseListSyntax)
Expand Down Expand Up @@ -9106,7 +9106,7 @@ public struct RawDeinitializerDeclSyntax: RawDeclSyntaxNodeProtocol, RawSyntaxTo

@_spi(RawSyntax)
public struct RawSubscriptDeclSyntax: RawDeclSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Accessor: RawSyntaxNodeProtocol {
case `accessors`(RawAccessorBlockSyntax)
case `getter`(RawCodeBlockSyntax)
Expand Down Expand Up @@ -9804,7 +9804,7 @@ public struct RawAccessorBlockSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {

@_spi(RawSyntax)
public struct RawPatternBindingSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Accessor: RawSyntaxNodeProtocol {
case `accessors`(RawAccessorBlockSyntax)
case `getter`(RawCodeBlockSyntax)
Expand Down Expand Up @@ -10745,7 +10745,7 @@ public struct RawPrecedenceGroupDeclSyntax: RawDeclSyntaxNodeProtocol, RawSyntax

@_spi(RawSyntax)
public struct RawPrecedenceGroupAttributeListSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: RawSyntaxNodeProtocol {
case `precedenceGroupRelation`(RawPrecedenceGroupRelationSyntax)
case `precedenceGroupAssignment`(RawPrecedenceGroupAssignmentSyntax)
Expand Down Expand Up @@ -11136,7 +11136,7 @@ public struct RawPrecedenceGroupAssociativitySyntax: RawSyntaxNodeProtocol, RawS

@_spi(RawSyntax)
public struct RawMacroDeclSyntax: RawDeclSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Signature: RawSyntaxNodeProtocol {
case `functionLike`(RawFunctionSignatureSyntax)
case `valueLike`(RawTypeAnnotationSyntax)
Expand Down Expand Up @@ -11661,7 +11661,7 @@ public struct RawCustomAttributeSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax

@_spi(RawSyntax)
public struct RawAttributeSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Argument: RawSyntaxNodeProtocol {
case `token`(RawTokenSyntax)
case `stringExpr`(RawStringLiteralExprSyntax)
Expand Down Expand Up @@ -11863,7 +11863,7 @@ public struct RawAttributeSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {

@_spi(RawSyntax)
public struct RawAttributeListSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: RawSyntaxNodeProtocol {
case `attribute`(RawAttributeSyntax)
case `customAttribute`(RawCustomAttributeSyntax)
Expand Down Expand Up @@ -11939,7 +11939,7 @@ public struct RawAttributeListSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {

@_spi(RawSyntax)
public struct RawSpecializeAttributeSpecListSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: RawSyntaxNodeProtocol {
case `labeledSpecializeEntry`(RawLabeledSpecializeEntrySyntax)
case `availabilityEntry`(RawAvailabilityEntrySyntax)
Expand Down Expand Up @@ -12264,7 +12264,7 @@ public struct RawTargetFunctionEntrySyntax: RawSyntaxNodeProtocol, RawSyntaxToSy

@_spi(RawSyntax)
public struct RawNamedAttributeStringArgumentSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum StringOrDeclname: RawSyntaxNodeProtocol {
case `string`(RawTokenSyntax)
case `declname`(RawDeclNameSyntax)
Expand Down Expand Up @@ -12699,7 +12699,7 @@ public struct RawDifferentiableAttributeArgumentsSyntax: RawSyntaxNodeProtocol,

@_spi(RawSyntax)
public struct RawDifferentiabilityParamsClauseSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Parameters: RawSyntaxNodeProtocol {
case `parameter`(RawDifferentiabilityParamSyntax)
case `parameterList`(RawDifferentiabilityParamsSyntax)
Expand Down Expand Up @@ -13946,7 +13946,7 @@ public struct RawExpressionStmtSyntax: RawStmtSyntaxNodeProtocol, RawSyntaxToSyn

@_spi(RawSyntax)
public struct RawSwitchCaseListSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: RawSyntaxNodeProtocol {
case `switchCase`(RawSwitchCaseSyntax)
case `ifConfigDecl`(RawIfConfigDeclSyntax)
Expand Down Expand Up @@ -14644,7 +14644,7 @@ public struct RawReturnStmtSyntax: RawStmtSyntaxNodeProtocol, RawSyntaxToSyntax

@_spi(RawSyntax)
public struct RawYieldStmtSyntax: RawStmtSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Yields: RawSyntaxNodeProtocol {
case `yieldList`(RawYieldListSyntax)
case `simpleYield`(RawExprSyntax)
Expand Down Expand Up @@ -14999,7 +14999,7 @@ public struct RawCatchItemListSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {

@_spi(RawSyntax)
public struct RawConditionElementSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Condition: RawSyntaxNodeProtocol {
case `expression`(RawExprSyntax)
case `availability`(RawAvailabilityConditionSyntax)
Expand Down Expand Up @@ -15671,7 +15671,7 @@ public struct RawThrowStmtSyntax: RawStmtSyntaxNodeProtocol, RawSyntaxToSyntax {

@_spi(RawSyntax)
public struct RawIfStmtSyntax: RawStmtSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum ElseBody: RawSyntaxNodeProtocol {
case `ifStmt`(RawIfStmtSyntax)
case `codeBlock`(RawCodeBlockSyntax)
Expand Down Expand Up @@ -15791,7 +15791,7 @@ public struct RawIfStmtSyntax: RawStmtSyntaxNodeProtocol, RawSyntaxToSyntax {

@_spi(RawSyntax)
public struct RawSwitchCaseSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Label: RawSyntaxNodeProtocol {
case `default`(RawSwitchDefaultLabelSyntax)
case `case`(RawSwitchCaseLabelSyntax)
Expand Down Expand Up @@ -16439,7 +16439,7 @@ public struct RawGenericRequirementListSyntax: RawSyntaxNodeProtocol, RawSyntaxT

@_spi(RawSyntax)
public struct RawGenericRequirementSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Body: RawSyntaxNodeProtocol {
case `sameTypeRequirement`(RawSameTypeRequirementSyntax)
case `conformanceRequirement`(RawConformanceRequirementSyntax)
Expand Down Expand Up @@ -19459,7 +19459,7 @@ public struct RawAvailabilitySpecListSyntax: RawSyntaxNodeProtocol, RawSyntaxToS

@_spi(RawSyntax)
public struct RawAvailabilityArgumentSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Entry: RawSyntaxNodeProtocol {
case `token`(RawTokenSyntax)
case `availabilityVersionRestriction`(RawAvailabilityVersionRestrictionSyntax)
Expand Down Expand Up @@ -19561,7 +19561,7 @@ public struct RawAvailabilityArgumentSyntax: RawSyntaxNodeProtocol, RawSyntaxToS

@_spi(RawSyntax)
public struct RawAvailabilityLabeledArgumentSyntax: RawSyntaxNodeProtocol, RawSyntaxToSyntax {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Value: RawSyntaxNodeProtocol {
case `string`(RawTokenSyntax)
case `version`(RawVersionTupleSyntax)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/SyntaxCollections.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public extension SyntaxCollection {
% end
public struct ${node.name}: SyntaxCollection, SyntaxHashable {
% if node.collection_element_choices:
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: SyntaxChildChoices {
% for choice_name in node.collection_element_choices:
% choice = NODE_MAP[choice_name]
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/SyntaxEnum.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//===----------------------------------------------------------------------===//

/// Enum to exhaustively switch over all different syntax nodes.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum SyntaxEnum {
case unknown(UnknownSyntax)
case token(TokenSyntax)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/SyntaxKind.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//===----------------------------------------------------------------------===//

/// Enumerates the known kinds of Syntax represented in the Syntax tree.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum SyntaxKind {
case token
case unknown
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/TokenKind.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//===----------------------------------------------------------------------===//

/// Enumerates the kinds of tokens in the Swift language.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum TokenKind: Hashable {
case eof
% for token in SYNTAX_TOKENS:
Expand Down Expand Up @@ -144,7 +144,7 @@ extension TokenKind: Equatable {
}

/// Plain token kind value, without an associated `String` value.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum RawTokenKind: Equatable, Hashable {
case eof
% for token in SYNTAX_TOKENS:
Expand Down
10 changes: 5 additions & 5 deletions Sources/SwiftSyntax/gyb_generated/SyntaxCollections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ extension DictionaryElementListSyntax: BidirectionalCollection {
/// as a regular Swift collection, and has accessors that return new
/// versions of the collection with different children.
public struct StringLiteralSegmentsSyntax: SyntaxCollection, SyntaxHashable {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: SyntaxChildChoices {
case `stringSegment`(StringSegmentSyntax)
case `expressionSegment`(ExpressionSegmentSyntax)
Expand Down Expand Up @@ -6109,7 +6109,7 @@ extension DesignatedTypeListSyntax: BidirectionalCollection {
/// as a regular Swift collection, and has accessors that return new
/// versions of the collection with different children.
public struct PrecedenceGroupAttributeListSyntax: SyntaxCollection, SyntaxHashable {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: SyntaxChildChoices {
case `precedenceGroupRelation`(PrecedenceGroupRelationSyntax)
case `precedenceGroupAssignment`(PrecedenceGroupAssignmentSyntax)
Expand Down Expand Up @@ -7162,7 +7162,7 @@ extension NonEmptyTokenListSyntax: BidirectionalCollection {
/// as a regular Swift collection, and has accessors that return new
/// versions of the collection with different children.
public struct AttributeListSyntax: SyntaxCollection, SyntaxHashable {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: SyntaxChildChoices {
case `attribute`(AttributeSyntax)
case `customAttribute`(CustomAttributeSyntax)
Expand Down Expand Up @@ -7458,7 +7458,7 @@ extension AttributeListSyntax: BidirectionalCollection {
/// A collection of arguments for the `@_specialize` attribute
///
public struct SpecializeAttributeSpecListSyntax: SyntaxCollection, SyntaxHashable {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: SyntaxChildChoices {
case `labeledSpecializeEntry`(LabeledSpecializeEntrySyntax)
case `availabilityEntry`(AvailabilityEntrySyntax)
Expand Down Expand Up @@ -8521,7 +8521,7 @@ extension BackDeployVersionListSyntax: BidirectionalCollection {
/// as a regular Swift collection, and has accessors that return new
/// versions of the collection with different children.
public struct SwitchCaseListSyntax: SyntaxCollection, SyntaxHashable {
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum Element: SyntaxChildChoices {
case `switchCase`(SwitchCaseSyntax)
case `ifConfigDecl`(IfConfigDeclSyntax)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/gyb_generated/SyntaxEnum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

/// Enum to exhaustively switch over all different syntax nodes.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum SyntaxEnum {
case unknown(UnknownSyntax)
case token(TokenSyntax)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/gyb_generated/SyntaxKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

/// Enumerates the known kinds of Syntax represented in the Syntax tree.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum SyntaxKind {
case token
case unknown
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/gyb_generated/TokenKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//

/// Enumerates the kinds of tokens in the Swift language.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum TokenKind: Hashable {
case eof
case associatedtypeKeyword
Expand Down Expand Up @@ -1132,7 +1132,7 @@ extension TokenKind: Equatable {
}

/// Plain token kind value, without an associated `String` value.
@frozen
@frozen // FIXME: Not actually stable, works around a miscompile
public enum RawTokenKind: Equatable, Hashable {
case eof
case associatedtypeKeyword
Expand Down
3 changes: 1 addition & 2 deletions Sources/_SwiftSyntaxMacros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
add_swift_host_library(_SwiftSyntaxMacros
ExpressionMacro.swift
Macro.swift
MacroEvaluationContext.swift
MacroResult.swift
MacroExpansionContext.swift
MacroSystem+Builtin.swift
MacroSystem+Examples.swift
MacroSystem.swift
Expand Down
Loading