Skip to content

[pigeon] Generating kotlin API produces setUp method that doesn't honour optional parameter, when called from Java, unless adding @JvmOverloads #149027

@diederikMrAwesome

Description

@diederikMrAwesome

Steps to reproduce

Generate a pigeon class to kotlin with the form:

@ConfigurePigeon(PigeonOptions(
    dartOut: 'lib/generated/overview_pigeon.dart',
    dartOptions: DartOptions(),
    kotlinOut:
        '../Android/app/reptile/src/main/java/com/example.reptile/flutter/pigeon/generated/OverviewPigeon.kt',
    kotlinOptions: KotlinOptions(
      errorClassName: "OverviewError",
      package: 'com.example.reptile.flutter.pigeon.generated',
    ),
    swiftOut:
        '../Objective-C/Reptile/Reptile/Pigeons/OverviewPigeon.swift'))
class Overview {
/// ...
}

This generates a setup method with the new messageChannelSuffix in the generated kotlin file.

 fun setUp(binaryMessenger: BinaryMessenger, api: HostOverviewApi?, messageChannelSuffix: String = "") {

When calling this method in java, the kotlin default parameter isn't visible. Unless you add the @JvmOverloads on the method on the kotlin class.

Expected results

Java can call the setUp method without the optional messageChannelSuffix parameter.

Actual results

All our Java code now needs to add an empty string as a third parameter. Unless the generated setup method is annotated with @JvmOverloads

Code sample

See above

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

flutter doctor -v

[✓] Flutter (Channel stable, 3.22.0, on Ubuntu 22.04.4 LTS 6.5.0-35-generic, locale en_ZA.UTF-8)
    • Flutter version 3.22.0 on channel stable at /home/diederik/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (2 weeks ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/diederik/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /home/diederik/apps/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2023.3)
    • Android Studio at /home/diederik/apps/android-studio/
    • Flutter plugin version 79.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /home/diederik/apps/android-studio/
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.89.1)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.84.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.4 LTS 6.5.0-35-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 124.0.6367.207

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions