Skip to content

Commit 90d2610

Browse files
Use wildcard CompanionStatic rename to surface all class companions
The previous commit enumerated 7 specific Kotlin companion classes by name across foundation-android (1), ui-graphics-android (1), and ui-text-android (5). That fixed those 7 but left 62 more classes with the same problem in just these three packages: ScrollState.Companion, LazyListState.Companion, BlendMode.Companion, Brush.Companion, Path.Companion, ImeAction.Companion, TextRange.Companion, AnnotatedString.Companion, and many others were still unreachable without raw JNI. Replace the per-class entries with the same wildcard XPath that kotlin-stdlib, okio-jvm, com.google.ai.edge.aicore, and com.google.mlkit genai-prompt already use: <attr path="/api/package/class[substring(@name,string-length(@name)-9) ='.Companion']" name="managedName">CompanionStatic</attr> This renames every nested *.Companion peer in the package to CompanionStatic, letting the binding generator emit `public static <Outer>.CompanionStatic Companion { get; }` on every outer class. After this change: foundation-android : 24 new static Companion accessors ui-graphics-android: 35 new static Companion accessors ui-text-android : 45 new static Companion accessors --- 104 total (vs. 7 in the previous revision) Interface companions are unaffected — the binding generator hoists them to top-level <Outer>Companion before this rename matches, so `Path.Companion`, `ImageBitmap.Companion`, `DrawScope.Companion`, etc. surface correctly via their hoisted peer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 227fa7b commit 90d2610

6 files changed

Lines changed: 896 additions & 511 deletions

File tree

source/androidx.compose.foundation/foundation-android/PublicAPI/PublicAPI.Unshipped.txt

Lines changed: 278 additions & 99 deletions
Large diffs are not rendered by default.

source/androidx.compose.foundation/foundation-android/Transforms/Metadata.xml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@
7777
`<Outer>.Companion`, which collides with the static `Companion` property the
7878
generator would otherwise emit on the outer class (a nested type and a
7979
property can't share a name), so the field is silently dropped and the
80-
singleton is only reachable via raw JNI. Rename the nested companion peer to
81-
`CompanionStatic` (matching the okio binding convention) so the generator can
82-
surface `public static KeyboardOptions.CompanionStatic Companion { get; }`,
83-
letting consumers write `KeyboardOptions.Companion.Default` directly.
84-
(Interface companions are unaffected — their peer is already hoisted/renamed,
85-
so they surface without help.)
80+
singleton is only reachable via raw JNI. Rename every nested `*.Companion`
81+
peer to `CompanionStatic` (the same wildcard pattern kotlin-stdlib, okio,
82+
aicore, and genai-prompt already use) so the generator surfaces
83+
`public static <Outer>.CompanionStatic Companion { get; }` on every outer
84+
class, letting consumers write e.g. `KeyboardOptions.Companion.Default`,
85+
`ScrollState.Companion.Saver`, `LazyListState.Companion.Saver` directly.
86+
(Interface companions are hoisted to top-level `<Outer>Companion` by the
87+
generator before this rename matches, so they're unaffected.)
8688
-->
87-
<attr path="/api/package[@name='androidx.compose.foundation.text']/class[@name='KeyboardOptions.Companion']" name="managedName">CompanionStatic</attr>
89+
<attr path="/api/package/class[substring(@name,string-length(@name)-9)='.Companion']" name="managedName">CompanionStatic</attr>
8890
</metadata>

0 commit comments

Comments
 (0)