Skip to content

Conversation

@mattt
Copy link
Owner

@mattt mattt commented Jan 5, 2026

Resolves #74

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR documents a limitation where the memberwise initializer synthesized by the @Generable macro is not visible within other macro bodies like #Playground. This is due to how Swift macros compose—one macro's expansion isn't visible during another macro's body expansion.

Key Changes:

  • Added documentation to the @Generable macro explaining the limitation and suggesting workarounds
  • Added commented example code demonstrating two workaround approaches: using the init(_ generatedContent:) initializer directly and defining a factory method

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Sources/AnyLanguageModel/Generable.swift Added doc comment with a note explaining that the synthesized memberwise initializer isn't visible inside other macro bodies and suggests workarounds
Tests/AnyLanguageModelTests/GenerableMacroTests.swift Added conditionally-compiled example code demonstrating workarounds for using @Generable types within #Playground macros

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattt mattt merged commit 8dc5a0f into main Jan 5, 2026
9 checks passed
@mattt mattt deleted the mattt/playground-caveats branch January 5, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memberwise initializer not recognized in #Playground

2 participants