Skip to content

ExplicitLambdaArgumentTypes imports the wrong class and collides on name importing. #323

@blipper

Description

@blipper

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions