Surface Kotlin object companions on Compose class bindings#1468
Draft
Copilot wants to merge 2 commits into
Draft
Surface Kotlin object companions on Compose class bindings#1468Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…ionStatic rename Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Kotlin object companion field visibility on outer class binding
Surface Kotlin object companions on Compose class bindings
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kotlin
objectcompanions on a class weren't surfaced as a staticCompanionproperty on the binding, forcing consumers to bootstrap the singleton through raw JNI (FindClass+GetStaticFieldID("Companion")+GetStaticObjectField) to reach members likeKeyboardOptions.Companion.Default.Root cause
The binder keeps a class's companion peer named
<Outer>.Companion. A nested type and a property can't share a name in C#, so the generator silently drops the staticCompanionfield. Interface companions are unaffected — their peer is hoisted/renamed to<Outer>Companion, so they already surface (Alignment.Companion,ContentScale.Companion, … work today).Changes
managedNamerename toCompanionStaticon the colliding nested peer (the convention already used by the okio binding), letting the generator emitpublic static <Outer>.CompanionStatic Companion { get; }. Applied per type inTransforms/Metadata.xml:foundation-android:KeyboardOptionsui-text-android:TextStyle,TextDecoration,FontWeight,FontFamily,FontStyleui-graphics-android:ColorPublicAPI.Unshipped.txtfor those three packages (companion-only delta).Scope notes
Targets class companions only — renaming an interface companion's peer would needlessly rename an already-public type. Several names from the issue need no change:
Alignment/ContentScalealready surface (interfaces),Modifieris a special interface companion, andMaterialTheme/ most*Defaultsare Kotlinobjects with no companion. The sameCompanionStaticrename generalizes to any future class with anobjectcompanion.