rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

ExplicitLambdaArgumentTypes imports the wrong class and collides on name importing.

Open blipper opened this issue 6 months ago • 0 comments

What version of OpenRewrite are you using?

I am using

  • LAtest

What is the smallest, simplest way to reproduce the problem?

package bar;
import foo.A;
class Foo {
    void foo(List<List<buzz.A> asouter) {
           asouter.forEach((asouter) -> {
               asouter.forEach(a) {}
         } 
    }
}

What did you expect to see?

import foo.A;
class Foo {
    void foo(List<List<buzz.A> asouter) {
           asouter.forEach((buzz.A asouter) -> {
               asouter.forEach(buzz.A a) {}
         } 
    }
}

What did you see instead?

import foo.A;
import buzz.A;
class Foo {
    void foo(List<List<buzz.A> asouter) {
           asouter.forEach((A asouter) -> {
               asouter.forEach(A a) {}
         } 
    }
}
}

Somehow the symbols are getting confused and picking form a different package. This also could be due to nested labmdas where the symbol has a fully qualifed name for a generic in the outer scope and a non-qualified name derived in the inner nested.

What is the full stack trace of any errors you encountered?

 error: a type with the same simple name is already defined by the single-type-import of A
  import buzz.A;
  ^

Are you interested in [contributing a fix to OpenRewrite]Yes

blipper avatar Aug 12 '24 23:08 blipper