Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Kotlin unsigned type metadata bug #984

Description

@jpobst

Context: #946
Context: dotnet/android-libraries#547

While updating AndroidX to XA 17.2, we found that the previous Kotlin issues around unsigned types have been fixed. However, there are some new issues that have been exposed:

#### Type Changed: Kotlin.UIntArray

Removed methods:

public bool Contains (uint element);
public static bool Contains (int[] arg0, int element);

Added methods:

public bool Contains (int element);
public static bool Contains (int[] arg0, uint element);

This regression should be investigated. Perhaps it is related to method overloads?

Activity

  1. added
    bugComponent does not function as intended
    generatorIssues binding a Java library (generator, class-parse, etc.)
    on May 12, 2022
  2. added this to the 7.0.0 milestone on May 12, 2022
  3. jpobst commented on Jul 7, 2022

    @jpobst
    ContributorAuthor

    Notes for future me:

    fun contains(element: UInt): Boolean
    operator fun <T> Array<out T>.contains(element: T): Boolean

    In these cases, the Kotlin signature is the same, thus the mangled Java method name is the same:

      public boolean contains-WZ4Q5Ns(int element) {
        return contains-WZ4Q5Ns(this.storage, element);
      }
      
      public static boolean contains-WZ4Q5Ns(int[] arg0, int element) {
        Intrinsics.checkNotNullParameter(arg0, "arg0");
        return ArraysKt.contains(arg0, element);
      }

    The mangled part seems to be a hash of the Kotlin parameter types of the method. Because they "match", Kotlin does not write its metadata for each method, it only writes one copy which is correct-ish for both methods:

    image

    (Note that the JvmSignature is ([II)Z even though there is only one ValueParameter.

    Thus, when more than one Java method matches the JvmName and the JvmName is "mangled" (contains a hyphen), we should apply the parameter fixups to all matching methods, even though the JvmSignature doesn't match.

  4. locked and limited conversation to collaborators on Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugComponent does not function as intendedgeneratorIssues binding a Java library (generator, class-parse, etc.)

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions