You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[class-parse, generator] Allow showing Kotlin internals via metadata (#793)
Fixes: #790
Kotlin compiled for Java Bytecode is an interesting beast, as it has
features which aren't directly supported by Java bytecode.
One such feature is visibility: Kotlin supports an [`internal`][0]
visibility on types and members:
internal class Example
Java doesn't have a direct equivalent to `internal`; instead,
Java Bytecode uses a visibility of *`public`*:
% javap Example.class
public final class Example {
public Example();
}
Commit 439bd83 added support to `Xamarin.Android.Tools.Bytecode.dll`
for parsing Kotlin metadata. The result is that Kotlin `internal`
are marked as *`private`*, which causes them to be *skipped* and not
present within `api.xml`, because `class-parse`
[doesn't write out `private` members][1].
The result was that `Metadata.xml` could not be used to mark Kotlin
`internal` types as `public`, as they didn't exist within `api.xml`,
and thus couldn't serve as a "target" for `Metadata.xml`.
Improve support for using `Metadata.xml` to update Kotlin `internal`
types by making the following changes:
* `XmlClassDeclarationBuilder` now emits *all* types, even
`private` types. This includes Kotlin `internal` types which
were changed to have `private` visibility.
* Kotlin `internal` members are emitted into `api.xml` with a new
`//*/@visibility` value of `kotlin-internal`.
These changes allow the Kotlin declaration:
internal class Example {
public fun pubFun() {}
internal fun intFun() {}
}
to be emitted into `api.xml` a'la:
<class name="Example" visibility="private" …>
<method name="pubFun" visibility="public" …/>
<method name="intFun$main" visibility="kotlin-internal" …/>
</class>
[0]: https://kotlinlang.org/docs/visibility-modifiers.html#modules
[0]: https://github.com/xamarin/java.interop/blob/b46598a254c20060b107312564e0ec0aee9e33d6/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs#L32-L33
0 commit comments