Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants