square / square/wire

Type is Map<String, *>? but Any was expected

Open
#2,359 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello, I got a problem when using the wire protobuf and grpc client.
I use latest version of wire. And got compile error Type mismatch: inferred type is Map<String, *>? but Any was expected
The grpc service is as follows:
rpc CreateOrder(RequestClass) returns (.google.protobuf.Struct);
Code generated:

  public override fun CreateOrder(): GrpcCall<RequestClass,  Map<String, *>?> =
      client.newCall(GrpcMethod(
      path = "/retail_core.v1.Retail/CreateOrder",
      requestAdapter = PaypalCreateOrderRequest.ADAPTER,
      responseAdapter = ProtoAdapter.STRUCT_MAP
  ))

ProtoAdapter.STRUCT_MAP return only Map<String, *>? witch is not subtype of Any
class GrpcMethod<S : Any, R : Any>

Can you add possibility to change adapter to custom or add @JvmSuppressWildCards or do STRUCT_MAP with Any return?

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 generated CreateOrder method and ProtoAdapter.STRUCT_MAP shown in the report, then trace GrpcMethod's S and R bounds to reproduce the Kotlin type mismatch. Done means the Struct response adapter is accepted by the generated gRPC client without the reported Map<String, *>? versus Any error, with a regression test if the relevant test location is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, kotlin
Domain
api, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.