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

Wrong code generated when extending interface with another that has the same name #259

Closed
jsenko opened this issue Oct 14, 2022 · 1 comment · Fixed by #261
Closed

Wrong code generated when extending interface with another that has the same name #259

jsenko opened this issue Oct 14, 2022 · 1 comment · Fixed by #261

Comments

@jsenko
Copy link

jsenko commented Oct 14, 2022

When extending an interface with another one that has the same name but comes from a different package, Roaster should add a fully qualified reference to the extending interface.
Here is a reproducer that can be run using jbang:

///usr/bin/env jbang "$0" "$@" ; exit $?

//DEPS org.jboss.forge.roaster:roaster-api:2.26.0.Final
//DEPS org.jboss.forge.roaster:roaster-jdt:2.26.0.Final

import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaInterfaceSource;

import static java.lang.System.out;

class Bug {

	public static void main(String[] args) {

		JavaInterfaceSource outer = Roaster.create(JavaInterfaceSource.class)
				.setPackage("outer")
				.setName("Buggy")
				.setPublic();

		JavaInterfaceSource inner = Roaster.create(JavaInterfaceSource.class)
				.setPackage("outer.inner")
				.setName("Buggy")
				.setPublic();

		inner.addInterface(outer);

		out.println("Expected:\n" +
				"package outer.inner;\n" +
				"public interface Buggy extends outer.Buggy {\n" +
				"}");

		out.println("Actual:");
		out.println(inner.toString());
	}
}

Is there a workaround (other than changing the name)? Thanks for any help!

@jsenko
Copy link
Author

jsenko commented Oct 14, 2022

We should also check for other similar cases is class source. If someone can point me in the right direction, I can try to contribute a fix.

gastaldi added a commit that referenced this issue Oct 15, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
gastaldi added a commit that referenced this issue Oct 15, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
gastaldi added a commit that referenced this issue Oct 15, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
gastaldi added a commit that referenced this issue Oct 18, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
gastaldi added a commit that referenced this issue Oct 18, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
gastaldi added a commit that referenced this issue Oct 18, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
gastaldi added a commit that referenced this issue Oct 18, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
gastaldi added a commit that referenced this issue Oct 18, 2022
…rHolder#addInterface(java.lang.String)

- Fixes #259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant