To Reproduce
Steps to reproduce the behavior:
- Kotlin version: 2.3.20
- Gradle version: 9.4.0
- kotlinx-rpc version: 0.11.0-grpc-185
- OS (Or at least KMP platform): iOS
- Minimal reproducer in code:
Connect org.jetbrains.kotlinx.rpc.plugin and add minimal configuration:
Add a proto file with the following contents:
syntax = "proto3";
import "google/protobuf/timestamp.proto"; // just add any import from google/protobuf
message SimpleResponse {
string result = 1;
}
-
Error description after compilation:
error: 'equals' overrides nothing. Potential signatures for overriding: fun equals(other: Any?): Boolean
-
Generated code:
import com.google.protobuf.kotlin.* // problem here
import ...
class SimpleResponseInternal: SimpleResponse.Builder, InternalMessage(fieldsWithPresence = 0) {
...
// here we got com.google.protobuf.kotlin.Any
override fun equals(other: Any?): Boolean {
checkRequiredFields()
if (this === other) return true
if (other == null || this::class != other::class) return false
other as SimpleResponseInternal
other.checkRequiredFields()
if (this.result != other.result) return false
return true
}
- Expected generated code:
import com.google.protobuf.kotlin.Timestamp // precision import, not *
...
class SimpleResponseInternal: SimpleResponse.Builder, InternalMessage(fieldsWithPresence = 0) {
// And now, as expected, we have 'kotlin.Any' here.
override fun equals(other: Any?): Boolean {
checkRequiredFields()
if (this === other) return true
if (other == null || this::class != other::class) return false
other as SimpleResponseInternal
other.checkRequiredFields()
if (this.result != other.result) return false
return true
}
Because we imported 'com.google.protobuf.kotlin.*' in the generated code, we also imported 'com.google.protobuf.kotlin.Any', and this causes a problem: now 'Any' in equals is not 'kotlin.Any', but 'com.google.protobuf.kotlin.Any', and this breaks the override of the equals method.
An interesting observation: the build succeeds on Android, but fails on iOS. I wonder why this is. I would expect the compiler to throw an error on Android as well, which is very strange.
To Reproduce
Steps to reproduce the behavior:
Connect
org.jetbrains.kotlinx.rpc.pluginand add minimal configuration:Add a proto file with the following contents:
Error description after compilation:
error: 'equals' overrides nothing. Potential signatures for overriding: fun equals(other: Any?): Boolean
Generated code:
Because we imported 'com.google.protobuf.kotlin.*' in the generated code, we also imported 'com.google.protobuf.kotlin.Any', and this causes a problem: now 'Any' in equals is not 'kotlin.Any', but 'com.google.protobuf.kotlin.Any', and this breaks the override of the equals method.
An interesting observation: the build succeeds on Android, but fails on iOS. I wonder why this is. I would expect the compiler to throw an error on Android as well, which is very strange.