Skip to content

Swift attached macro causes circular reference when used with inner type extension #76037

Open
@edudnyk

Description

@edudnyk

Description

Taking equatable extension macro implementation from Swift Macro Examples in swift-syntax repository, and having the following code:

@equatable
struct Pet {
  struct Dog {}

  let name: String
}

extension Pet.Dog {}

the compiler throws “circular reference resolving attached macro ‘equatable’” error (see screenshot).
Screenshot

Steps to Reproduce

  1. Clone https://github.com/edudnyk/swift-syntax.git
  2. Checkout branch attached-macro-bugreport.
  3. Open Package.swift in Xcode.
  4. Open Examples/Sources/MacroExamples/Playground/ExtensionMacrosPlayground.swift
  5. Build the MacroExamplesPlayground target.

Apple Feedback ID: FB14887944

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.swift macroFeature → declarations: Swift `macro` declarations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions