square / square/wire

Compile errors if a field is named 'com'

Open
#1,881 3 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

The following proto file will not build using wire:

syntax="proto3";

message Simple {
    int32 com = 1;
}

Fine if I wasn't so lazy and called my field centre_of_mass ;-)

Generates the follwing errors:

C:\prog\ToFVe\Android\AvaCloneApp\app\build\tmp\kapt3\stubs\debug\Simple.java:6: error: int cannot be dereferenced
    @com.squareup.wire.WireField(tag = 1, adapter = "com.squareup.wire.ProtoAdapter#INT32", label = com.squareup.wire.WireField.Label.OMIT_IDENTITY)
C:\prog\ToFVe\Android\AvaCloneApp\app\build\tmp\kapt3\stubs\debug\Simple.java:6: error: an enum annotation value must be an enum constant
    @com.squareup.wire.WireField(tag = 1, adapter = "com.squareup.wire.ProtoAdapter#INT32", label = com.squareup.wire.WireField.Label.OMIT_IDENTITY)
                                                                                                                                     ^

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

Reproduce the failure with the proto shown in the issue and inspect the generated kapt stubs at Simple.java, especially the annotation for the field named com. Trace that output through Wire’s code-generation entry point, then add a regression test showing that the generated source compiles for this field name.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
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.