Skip to content

Comments

Support exporting traits on Records#2820

Draft
joe-p wants to merge 5 commits intomozilla:mainfrom
joe-p:feat/record_traits
Draft

Support exporting traits on Records#2820
joe-p wants to merge 5 commits intomozilla:mainfrom
joe-p:feat/record_traits

Conversation

@joe-p
Copy link

@joe-p joe-p commented Feb 12, 2026

This PR adds support for records implementing trait interfaces (previously only objects could). On the Kotlin side this is straightforward. The record's data class declaration includes the trait interfaces. On the Swift side, the main design decision is around AnyObject. Existing ...Protocol types all extend AnyObject, which prevents value types (structs) from conforming. To solve this without breaking existing code, a new Any...Protocol is generated without the AnyObject constraint, and the existing ...Protocol inherits from both AnyObject and Any...Protocol. Records then conform to Any...Protocol.

It should be noted that I am not super familiar with Swift, Kotlin, or the uniffi codebase, so I did use Claude for some of the work in this PR.

Closes #2819

TODO:

  • Update docs
  • Make sure kotlin is passing tests (don't have it setup locally)
  • Scope out any work needed for python

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.

Enable exported foreign trait implementations on Records

1 participant