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

Nested Type name clashes within same package #860

Open
wanyingd1996 opened this issue Dec 29, 2021 · 1 comment
Open

Nested Type name clashes within same package #860

wanyingd1996 opened this issue Dec 29, 2021 · 1 comment

Comments

@wanyingd1996
Copy link

When we have

interface Component {
  interface NestedType;
}

If we want to generate a ComponentImpl that reference a type that has the same simple name as a nested type in Component, then there will be a type name clash.

package test;
import test.sub.NestedType;

ComponentImpl implements Component {
  NestedType fun() {}
}

There is a avoidClashesWithNestedClasses can help with workaround the issue, it will keep the package prefix of NestedType in ComponentImpl. Then the generated code will be like

package test;

ComponentImpl implements Component {
  test.sub.NestedType fun() {}
}

But if the external Nested type is within the same package.

ComponentImpl implements Component {
  NestedType
}

The package prefix will gets stripped anyways. So even I added avoidClashesWithNestedClasses, it will still clash.

I think it is because in

// If the class is in the same package, we're done.
, Javapoet missed a check to keep the package prefix.

Can someone file a fix for it? Thanks!

@BigJIU
Copy link

BigJIU commented Apr 21, 2022

I'm working on this issue and will try to fix it.

And now it's done

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

No branches or pull requests

2 participants