square / square/wire

Fail with error when a field is identically named as the options static field

Open
#1,301 1 comment 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

Consider the following proto definition:

message Testing {
  optional string field = 1 [(squareup.someOption) = 123];
  optional string FIELD_OPTIONS_FIELD = 2;
}

This will generate a Java class containing the following incorrect code:

  public static final FieldOptions FIELD_OPTIONS_FIELD = new FieldOptions.Builder()
      .someOption(123)
      .build();
  ....
  @WireField(
      tag = 2,
      adapter = "com.squareup.wire.ProtoAdapter#STRING"
  )
  public final String FIELD_OPTIONS_FIELD;

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 issue from the provided proto definition and inspect the generated Java class, focusing on the collision between the static FIELD_OPTIONS_FIELD member and the generated message field. Confirm that the generated class no longer declares conflicting members and remains compilable.

Written by the indexing model from the issue text.

Assessment

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