Hi, i tried the setup from the <https://kotlin.git...
# kotlinx-rpc
m
Hi, i tried the setup from the Configuration docs with a simple sample as well as with one of our main production services. One i executed on my mac the other on Jenkins Runners. In all cases i see:
e: 'equals' overrides nothing. Potential signatures for overriding:
expect fun equals(other: Any?): Boolean
e: Operator '===' cannot be applied to 'HelloRequestInternal' and 'Any?'.
Is this a known issue or misconfiguration? More details from my coding agent in the thread.
Bug: Generated
equals
and
===
in
_rpc_internal
classes fail to compile with Kotlin 2.3.0 Plugin version:
kotlinx-rpc 0.11.0-grpc-185
Kotlin version:
2.3.0
Gradle version:
9.4.0
Configuration:
rpc { protoc() }
with Kotlin Multiplatform (JVM + iOS targets), protos in
src/commonMain/proto
Description: The
protoc-gen-kotlin-multiplatform
code generator produces
_rpc_internal
classes that extend
InternalMessage
and contain
override fun equals(other: Any?)
and
if (this === other)
statements that fail to compile. Example generated code (e.g.
test/_rpc_internal/Test.kt
): class HelloRequestInternal: HelloRequest.Builder, InternalMessage(fieldsWithPresence = 1) { // ... override fun equals(other: Any?): Boolean { // ERROR: 'equals' overrides nothing checkRequiredFields() if (this === other) return true // ERROR: Operator '===' cannot be applied if (other == null || this::class != other::class) return false other as HelloRequestInternal // ... } } Compiler errors: e: 'equals' overrides nothing. Potential signatures for overriding: expect fun equals(other: Any?): Boolean e: Operator '===' cannot be applied to 'HelloRequestInternal' and 'Any?'. This affects every generated message class that has fields with presence tracking. The issue appears to be that
InternalMessage
does not expose
equals
as
open
, or there is a mismatch between the generated
override
signature and what Kotlin 2.3.0 expects in a
commonMain
(expect/actual) context. Reproduction: Create a KMP project with
jvm()
,
iosArm64()
,
iosSimulatorArm64()
targets Add any
.proto
file with a message containing fields to
src/commonMain/proto/
Configure
rpc { protoc() }
1. Run
./gradlew compileCommonMainKotlinMetadata
The
bufGenerateCommonMain
task succeeds, but
compileCommonMainKotlinMetadata
fails on every generated
_rpc_internal
class.
j
Hi! Thanks for the bug report! I think I might know what’s causing this. Do your proto files import well-known types, for example:
Copy code
import "google/protobuf/empty.proto";
Also, could you check whether the
Any
parameter in the generated equals method resolves to
com.google.protobuf.kotlin.Any
instead of
kotlin.Any
? If yes, we have a bug in our name resolution which causes a type conflict.
a
Hi! Can you also please share the full minimal repro proto file too?
m
Hi, thank you for the quick response. That's a minimalistic proto:
syntax = "proto3";
package test;
import "google/protobuf/any.proto";
message MyMessage {
google.protobuf.Any payload = 1;
}
service MyService {
rpc GetMessage(MyMessage) returns (MyMessage);
}
1. With the star import (
import com.google.protobuf.kotlin.*
) --
compileCommonMainKotlinMetadata
FAILS with
'equals' overrides nothing
2. Without the star import --
compileCommonMainKotlinMetadata
SUCCEEDS
a
Yep, I found the root cause. I fixed the same issue some time ago, nut turns out only on Kotlin/JVM for some reason. Will put the fix here too, that's for the report
m
Thanks again for the quick fix. Would it be possible to release another DEV version? Without that we can not continue our evaluation.
a
I'll try to do a release today, but no promises, we have problem with TC unrelated to us right now, unfortunatelly