Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DifferentNameButSame gives invalid suggestion on an inner class new instance #2094

Closed
ZacSweers opened this issue Jan 13, 2021 · 1 comment · Fixed by #2115
Closed

DifferentNameButSame gives invalid suggestion on an inner class new instance #2094

ZacSweers opened this issue Jan 13, 2021 · 1 comment · Fixed by #2115

Comments

@ZacSweers
Copy link

ZacSweers commented Jan 13, 2021

Description of the problem / feature request:

Given this snippet, the DifferentNameButSame check warns

ServerFeatureFlagProcessor processor = new ServerFeatureFlagProcessor();
// Fails on this line
ServerFeatureFlagProcessor.TestBackdoor testBackdoor = processor.new TestBackdoor();

Suggesting this, which is invalid syntax

error: [DifferentNameButSame] This type is referred to in different ways within this file, which may be confusing.
    ServerFeatureFlagProcessor.TestBackdoor testBackdoor = processor.new TestBackdoor();
                                                                         ^
    (see https://errorprone.info/bugpattern/DifferentNameButSame)
  Did you mean 'ServerFeatureFlagProcessor.TestBackdoor testBackdoor = processor.new ServerFeatureFlagProcessor.TestBackdoor();'?

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

The above snippet should be fairly explanatory

What version of Error Prone are you using?

2.5.0

@ZacSweers ZacSweers changed the title DifferentNameButSame doesn't handle inner classes well DifferentNameButSame gives invalid suggestion on an inner class new instance Jan 13, 2021
@cushon
Copy link
Collaborator

cushon commented Jan 14, 2021

(This isn't fixed yet, but I added a repro in 0b7015e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants