square / square/wire

JavaScript name hashCode is generated for different inherited members [Kotlin Multiplatform] [JS]

Open
#2,948 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

PR welcome!
Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

In a Kotlin Multiplatform project that targets JS, a Wire generated class shows this error in its constructor: JavaScript name hashCode is generated for different inherited members: var hashCode: Int and fun hashCode(): Int.

image

Setting buildersOnly = true in the plugin configuration (as shown in Wire's js sample) still gives the same error.

Fortunately, the build is not broken by that error and the class can still be used without problems, but since I noticed it I thought it was worth reporting it.

Maybe this is a duplicate of #1424, but that issue doesn't have any progress and it is inactive since 2020.

Reproduction Steps
  • Create a new Kotlin Multiplatform project with the Android Studio "New project..." wizard
  • Add js as one of the targets
  • Add wire gradle plugin and wire-runtime dependency and add the wire configuration block in the build.gradle.kts file
  • Create a simple .proto file in commonMain/proto, mine is:
    syntax = "proto2";
    
    message Position {
      required float x = 1;
      required float y = 2;
    }
    
  • Run the build and check the generated class
  • NOTE: if the error doesn't show up, go to "File -> Invalidate Caches...", check all the checkboxes and press "Invalidate and Restart", then resync and rebuild the project
Environment

IDE: Android Studio Jellyfish | 2023.3.1
Kotlin Version: 1.9.24
Wire Version: both 4.9.9 and 5.0.0-alpha01 (I didn't test older versions)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JS sample's build.gradle.kts and the reproduced commonMain/proto Position definition, using the listed Kotlin, Wire, and JS setup. Compare the generated class with buildersOnly enabled and confirm the JavaScript hashCode diagnostic; done means the diagnostic is no longer produced while the generated class remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, kotlin
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.