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): KMP
- Minimal reproducer in code:
Connect org.jetbrains.kotlinx.rpc.plugin and add minimal configuration:
Add a proto file with the following contents in commonMain/proto:
syntax = "proto3";
message SubmitAuthResponse {
string submit_result = 1;
oneof result {
string finished = 101;
int64 next_challenge = 102;
}
}
-
Error description after compilation:
Unresolved reference. None of the following candidates is applicable because of a receiver type mismatch:
fun SubmitAuthResponse.Result.oneOfHashCode(): Int
-
Generated code:
class SubmitAuthResponseInternal: SubmitAuthResponse.Builder, InternalMessage(fieldsWithPresence = 0) {
...
override var submitResult: String by MsgFieldDelegate { "" }
override var result: SubmitAuthResponse.Result? = null
override fun hashCode(): Int {
checkRequiredFields()
var result = submitResult.hashCode()
result = 31 * result + (result?.oneOfHashCode() ?: 0) // error here
return result
}
- Expected generated code:
class SubmitAuthResponseInternal: SubmitAuthResponse.Builder, InternalMessage(fieldsWithPresence = 0) {
...
override var submitResult: String by MsgFieldDelegate { "" }
override var result: SubmitAuthResponse.Result? = null
override fun hashCode(): Int {
checkRequiredFields()
var result = submitResult.hashCode()
result = 31 * result + (this.result?.oneOfHashCode() ?: 0) // used this.result
return result
}
In other words, the problem is that the generated code needs to refer to objects more precisely. I think it's worth using this throughout the generated code to avoid such cases.
To Reproduce
Steps to reproduce the behavior:
Connect
org.jetbrains.kotlinx.rpc.pluginand add minimal configuration:Add a proto file with the following contents in commonMain/proto:
Error description after compilation:
Unresolved reference. None of the following candidates is applicable because of a receiver type mismatch:
fun SubmitAuthResponse.Result.oneOfHashCode(): Int
Generated code:
In other words, the problem is that the generated code needs to refer to objects more precisely. I think it's worth using
thisthroughout the generated code to avoid such cases.