-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
review fix: Manage generics from Interface in shadow mode #1914
Merged
Merged
Changes from 15 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
2bead30
test: superInterface on shadow type miss actual type arguments
pvojtechovsky 45f01a5
Provide a first mechanism to manage generic in interfaces even in sha…
surli 9634fe2
improve test
pvojtechovsky 05ad69d
Fix last assert
surli 5a9e5f7
Try to fix TypeParameter resolution
surli 5298e3a
Fix last erroring test
surli b6f01aa
Fix checkstyle
surli abee610
improve test
pvojtechovsky 7fe0735
Change the visitor to manage generic interfaces directly
surli 602fb25
Fix some tests
surli 7aebb87
test qualified names of superinterfaces
pvojtechovsky f154c96
Fix qualified name
surli 2727805
test: parent of CtTypeReference is initialized, check getSuperClass
pvojtechovsky ab54f46
fix parent of CtTypeReferences.getSuperInterfaces()
pvojtechovsky e8b0154
Manage superClass: first fix
surli 737569c
Merge remote-tracking branch 'inria/master' into fix-superiface-args
surli f6c463c
Fix documentation
surli 9a950a6
test bound type of act type args of type references
pvojtechovsky 1f55f22
added comments
pvojtechovsky 674bf52
Improve JavaReflectionVisitor to manage a cache of visited generics p…
surli ae4154f
Fix checkstyle and fix embarassing Enum<E extends Enum<E>> loops in g…
surli ab1cc3f
test: shadow CtType equals source based CtType
pvojtechovsky 0774320
Manage the case when <T extends Object> implicitely
surli 5341c64
Fix a bug with annotation
surli e911fee
Merge remote-tracking branch 'inria/master' into fix-superiface-args
surli e7a9218
Fix case of annotations
surli a019d0a
Fix some more errors
surli ffc691b
support repetitive usage of EqualsChecker
pvojtechovsky 2ae66d8
improve error printing
pvojtechovsky 1e9ed50
fixes
pvojtechovsky 1d69b71
JUST FOR DEBUGGING
pvojtechovsky 1047448
up
pvojtechovsky aeab784
Merge remote-tracking branch 'origin/master' into fix-superiface-args
pvojtechovsky 9f77ac4
up
pvojtechovsky b66acca
ignore implicit Enum constructor, ignore synthetic fields
pvojtechovsky 0f80026
fix: setModifiers(Collections.emptySet()) resets modifiers now
pvojtechovsky 6a37d65
enum value is always public static final, ignore synthetic typemembers
pvojtechovsky e390048
fix handling of upper bound of WildcardType
pvojtechovsky a3aa771
fix: actual type arguments on array type reference
pvojtechovsky 1e47c9f
feat: EqualsVisitor can report which attribute is not equal
pvojtechovsky 2fc84bb
fix and ignore differences in modifiers
pvojtechovsky 10c7e4f
fix: visibility of enum values
pvojtechovsky 9a60870
handle static interface methods with body well
pvojtechovsky f48be3b
fixes
pvojtechovsky de9a7a4
Merge remote-tracking branch 'origin/master' into fix-superiface-args
ce156d5
Merge remote-tracking branch 'origin/master' into fix-superiface-args
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,9 @@ public <T> void visitClass(Class<T> clazz) { | |
clazz.getPackage(); | ||
} | ||
if (clazz.getSuperclass() != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it ok that the check is not on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I certainly should change that one for safety. |
||
visitClassReference(clazz.getSuperclass()); | ||
visitClassReference(clazz.getGenericSuperclass()); | ||
} | ||
for (Class<?> anInterface : clazz.getInterfaces()) { | ||
for (Type anInterface : clazz.getGenericInterfaces()) { | ||
visitInterfaceReference(anInterface); | ||
} | ||
for (Annotation annotation : clazz.getDeclaredAnnotations()) { | ||
|
@@ -82,7 +82,7 @@ public <T> void visitInterface(Class<T> clazz) { | |
if (clazz.getPackage() != null) { | ||
clazz.getPackage(); | ||
} | ||
for (Class<?> anInterface : clazz.getInterfaces()) { | ||
for (Type anInterface : clazz.getGenericInterfaces()) { | ||
visitInterfaceReference(anInterface); | ||
} | ||
for (Annotation annotation : clazz.getDeclaredAnnotations()) { | ||
|
@@ -338,6 +338,32 @@ public <T> void visitArrayReference(Class<T> typeArray) { | |
} | ||
} | ||
|
||
@Override | ||
public <T> void visitClassReference(ParameterizedType type) { | ||
Type rawType = type.getRawType(); | ||
|
||
if (!(rawType instanceof Class)) { | ||
throw new UnsupportedOperationException("Rawtype of the parameterized type should be a class."); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
Class<T> classRaw = (Class<T>) rawType; | ||
if (classRaw.getPackage() != null) { | ||
visitPackage(classRaw.getPackage()); | ||
} | ||
if (classRaw.getEnclosingClass() != null) { | ||
visitClassReference(classRaw.getEnclosingClass()); | ||
} | ||
|
||
for (Type generic : type.getActualTypeArguments()) { | ||
if (generic instanceof TypeVariable) { | ||
visitTypeParameter((TypeVariable<?>) generic); | ||
} else { | ||
visitType(generic); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public <T> void visitClassReference(Class<T> clazz) { | ||
if (clazz.getPackage() != null && clazz.getEnclosingClass() == null) { | ||
|
@@ -348,6 +374,17 @@ public <T> void visitClassReference(Class<T> clazz) { | |
} | ||
} | ||
|
||
@Override | ||
public <T> void visitClassReference(Type type) { | ||
if (type instanceof Class) { | ||
visitClassReference((Class) type); | ||
} else if (type instanceof ParameterizedType) { | ||
visitClassReference((ParameterizedType) type); | ||
} else { | ||
throw new UnsupportedOperationException("Only type with class or ParameterizedType are supported."); | ||
} | ||
} | ||
|
||
@Override | ||
public <T> void visitInterfaceReference(Class<T> type) { | ||
if (type.getPackage() != null) { | ||
|
@@ -356,6 +393,48 @@ public <T> void visitInterfaceReference(Class<T> type) { | |
if (type.getEnclosingClass() != null) { | ||
visitClassReference(type.getEnclosingClass()); | ||
} | ||
|
||
for (TypeVariable<Class<T>> generic : type.getTypeParameters()) { | ||
visitTypeParameter(generic); | ||
} | ||
} | ||
|
||
@Override | ||
public <T> void visitInterfaceReference(ParameterizedType type) { | ||
Type rawType = type.getRawType(); | ||
|
||
if (!(rawType instanceof Class)) { | ||
throw new UnsupportedOperationException("Rawtype of the parameterized type should be a class."); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
Class<T> classRaw = (Class<T>) rawType; | ||
|
||
if (classRaw.getPackage() != null) { | ||
visitPackage(classRaw.getPackage()); | ||
} | ||
if (classRaw.getEnclosingClass() != null) { | ||
visitClassReference(classRaw.getEnclosingClass()); | ||
} | ||
|
||
for (Type generic : type.getActualTypeArguments()) { | ||
if (generic instanceof TypeVariable) { | ||
visitTypeParameter((TypeVariable<?>) generic); | ||
} else { | ||
visitType(generic); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public <T> void visitInterfaceReference(Type type) { | ||
if (type instanceof Class) { | ||
visitInterfaceReference((Class) type); | ||
} else if (type instanceof ParameterizedType) { | ||
visitInterfaceReference((ParameterizedType) type); | ||
} else { | ||
throw new UnsupportedOperationException("Only type with class or ParameterizedType are supported."); | ||
} | ||
} | ||
|
||
private <T> List<RtMethod> getDeclaredMethods(Class<T> clazz) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case should not happen after my change in
CtTypeReference#getSuperInterfaces
. Let's rollback this change. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked and I have the following broken test if I remove it: GenericsTest#testTypeParameterReferenceAsActualTypeArgument.