swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.3k stars 10.34k forks source link

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

Open edudnyk opened 3 weeks ago

edudnyk commented 3 weeks ago

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

ahoppen commented 3 weeks ago

Synced to Apple’s issue tracker as rdar://134489854

ahoppen commented 3 weeks ago

Moving to the compiler repo because this is about error messages generated by the compiler.