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

Annotation with named element does not get annotation type package marked implicit #3281

Closed
slarse opened this issue Mar 4, 2020 · 2 comments · Fixed by #3285
Closed

Annotation with named element does not get annotation type package marked implicit #3281

slarse opened this issue Mar 4, 2020 · 2 comments · Fixed by #3285

Comments

@slarse
Copy link
Collaborator

slarse commented Mar 4, 2020

Hello,

I ran into an issue where the package of the annotation type of an annotation does not get marked implicit, even though it is. It only happens when named elements are used (e.g. writing value = "unchecked" instead of just "unchecked"). It does not appear to affect Launcher.parseClass, I've only experienced the issue when building an entire model.

I've inlined a minimal test case that reproduces the issue. I had no idea of where to put it for a PR (and I don't have a fix for the problem), so inlining the test case was the best I could come up with.

@Test
public void test_AnnotationWithNamedElement_HasImplicitAnnotationTypePackage() throws Exception {
	Launcher launcher = new Launcher();
	launcher.addInputResource(
            new VirtualFile(
                "class Cls { @SuppressWarnings(value=\"unchecked\") void meth() {} }"));

	CtModel model = launcher.buildModel();
	List<CtElement> elems = model.getElements(e -> e instanceof CtAnnotation);

	assertEquals(1, elems.size());
	CtAnnotation<?> annotation = (CtAnnotation<?>) elems.get(0);
	assertTrue(annotation.getAnnotationType().getPackage().isImplicit());
}

It passes fine if you remove the value= from the annotation.

@slarse
Copy link
Collaborator Author

slarse commented Mar 4, 2020

Now that I think about it, I think this may not be limited to annotations as I've encountered fully qualified names pretty-printed in places that I did not expect them (using ignoreImplicit=false in the printer). I unfortunately don't have the output saved, but I will most assuredly encounter the same problems again if they actually exist as I'm operating on a fixed data set.

@monperrus
Copy link
Collaborator

monperrus commented Mar 5, 2020 via email

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

Successfully merging a pull request may close this issue.

2 participants