-
Notifications
You must be signed in to change notification settings - Fork 9
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
Remove mirror holder #100
base: master
Are you sure you want to change the base?
Remove mirror holder #100
Conversation
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.
Thanks for looking into how to clean this up!
@@ -117,8 +120,7 @@ public void handleBinaryTree(AnnotatedTypeMirror atm, BinaryTree binaryTree) { | |||
} | |||
} | |||
|
|||
private static class UniverseInferencePropagationTreeAnnotater | |||
extends PropagationTreeAnnotator { | |||
private class UniverseInferencePropagationTreeAnnotater extends PropagationTreeAnnotator { | |||
public UniverseInferencePropagationTreeAnnotater(AnnotatedTypeFactory atypeFactory) { |
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.
Is this a reference to the enclosing class? Or to the realTypeFactory
?
By making the class non-static, there is now another type factory in scope and you access the qualifiers through that...
|
||
public UniverseInferenceVisitor( | ||
UniverseInferenceChecker checker, | ||
InferenceChecker ichecker, | ||
BaseAnnotatedTypeFactory factory, | ||
boolean infer) { | ||
super(checker, ichecker, factory, infer); | ||
|
||
ANY = AnnotationBuilder.fromClass(elements, Any.class); |
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.
Yet another copy. That's the reason why the "holder" contained all these fields. Instead of duplicating them, see whether you can make the access nice through one copy in the real type factory.
if (elt.getKind() == ElementKind.CONSTRUCTOR | ||
&& type instanceof AnnotatedTypeMirror.AnnotatedExecutableType) { | ||
((AnnotatedTypeMirror.AnnotatedExecutableType) type) | ||
.getReturnType() | ||
.addMissingAnnotations(Arrays.asList(UniverseAnnotationMirrorHolder.SELF)); | ||
.addMissingAnnotations(Arrays.asList(atm.SELF)); |
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.
Please rename atm
to realTypeFactory
or something else more suitable (all other uses of atm
in this file are for AnnotatedTypeMirror
, with some uses confusingly being named type
).
|| AnnotatedTypes.containsModifier(atpb.getLowerBound(), LOST)) { | ||
if (AnnotatedTypes.containsModifier( | ||
atpb.getUpperBound(), | ||
((UniverseAnnotatedTypeFactory) atypeFactory).LOST) |
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.
You have a few casts like that, maybe add a field.
@@ -32,28 +25,37 @@ protected AnnotationMirror combineAnnotationWithAnnotation( | |||
assert receiverAnnotation != null; | |||
assert declaredAnnotation != null; | |||
|
|||
if (AnnotationUtils.areSame(receiverAnnotation, SELF)) { | |||
if (AnnotationUtils.areSame( | |||
receiverAnnotation, ((UniverseAnnotatedTypeFactory) atypeFactory).SELF)) { |
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.
Same comment about extracting the casts by adding a field or even just a local variable here.
public UniverseCombineConstraintEncoder( | ||
Lattice lattice, Map<AnnotationMirror, Integer> typeToInt) { | ||
super(lattice, typeToInt); | ||
Set<AnnotationMirror> allTypes = typeToInt.keySet(); | ||
for (AnnotationMirror am : allTypes) { |
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.
What is this doing?
Fixes #38