Skip to content

fix: qualify type references in @Generable macro to avoid name collisions#44

Merged
christopherkarani merged 1 commit intochristopherkarani:mainfrom
kylebrowning:fix-qualify-schema-type-references
Apr 1, 2026
Merged

fix: qualify type references in @Generable macro to avoid name collisions#44
christopherkarani merged 1 commit intochristopherkarani:mainfrom
kylebrowning:fix-qualify-schema-type-references

Conversation

@kylebrowning
Copy link
Copy Markdown
Contributor

Summary

The @Generable macro emits unqualified type references (GenerationSchema, GeneratedContent, Generable, etc.) in its generated code. When a consumer imports both Conduit and another framework that defines types with the same names (e.g., FluentKit defines Schema, Vapor projects commonly import both), compilation fails with ambiguity errors:

error: 'Schema' is ambiguous for type lookup in this context

This PR qualifies all Conduit type references in the macro's generated code with the Conduit. module prefix, so they resolve correctly regardless of what other modules the consumer imports.

Changes

  • GenerationSchemaConduit.GenerationSchema
  • GenerationSchema.PropertyConduit.GenerationSchema.Property
  • GeneratedContentConduit.GeneratedContent
  • GenerationIDConduit.GenerationID
  • ConvertibleFromGeneratedContentConduit.ConvertibleFromGeneratedContent
  • GenerableConduit.Generable

Only string literals producing generated code are changed — the macro plugin's own internal Swift code is untouched.

Test plan

  • swift build passes on the Conduit repo
  • Verify a project importing both Conduit and FluentKit can use @Generable without ambiguity errors

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 583c724b78

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

inheritanceClause: InheritanceClauseSyntax(
inheritedTypes: InheritedTypeListSyntax([
InheritedTypeSyntax(type: TypeSyntax(stringLiteral: "Generable"))
InheritedTypeSyntax(type: TypeSyntax(stringLiteral: "Conduit.Generable"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove Conduit. qualification from generated type names

Using Conduit.Generable (and similar Conduit.* references generated throughout this macro) breaks expansion for normal clients because the Conduit module itself defines a top-level Conduit type (Sources/ConduitFacade/ConduitFacade.swift), so lookup resolves Conduit as struct Conduit instead of the module and emits errors like 'Generable' is not a member type of struct 'Conduit.Conduit'. Any project that imports Conduit and applies @Generable will hit this compile failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was added because Schema is a widely used type name, and if you import something that uses that name the macro will be ambiguous and your code fails to compile.

@christopherkarani
Copy link
Copy Markdown
Owner

@kylebrowning yes this makes sense!

@christopherkarani christopherkarani merged commit 6de4ebb into christopherkarani:main Apr 1, 2026
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.

2 participants