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

fix: Shadow classes should be interpreted according to their kind (enum, interface, etc) #1806

Merged
merged 3 commits into from
Jan 3, 2018

Conversation

Egor18
Copy link
Contributor

@Egor18 Egor18 commented Jan 2, 2018

Failing test for #1791.
As you can see, test fails, for the enum from jar.

Class from EnumJar.jar:


public class EnumJar {

	enum Colors { Red, Black, White };
}

@surli surli changed the title Failing test case for #1791 fix: Shadow classes should be interpreted according to their kind (enum, interface, etc) Jan 3, 2018
@pvojtechovsky pvojtechovsky merged commit 677d100 into INRIA:master Jan 3, 2018
@pvojtechovsky
Copy link
Collaborator

Thank you @Egor18 for excellent reporting of problem including test case!
Thank you @simon for taking care!

@Egor18
Copy link
Contributor Author

Egor18 commented Jan 3, 2018

Thank you.

@@ -61,7 +61,15 @@ public void visitPackage(Package aPackage) {
visitField(field);
}
for (Class<?> aClass : clazz.getDeclaredClasses()) {
visitClass(aClass);
if (aClass.isAnnotation()) {
visitAnnotationClass((Class<Annotation>) aClass);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will produce class cast exception.
The correct type is Class<? extends Annotation>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this code from there:

public <T, R extends CtType<T>> R scan(Class<T> clazz) {

and apparently it's used for 2 years... But PR with a failing test case is welcome :)

@Egor18 Egor18 deleted the test_enum_type branch January 4, 2018 13:46
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 this pull request may close these issues.

4 participants