Remove mirror holder#100
Conversation
wmdietl
left a comment
There was a problem hiding this comment.
Thanks for looking into how to clean this up!
| private static class UniverseInferencePropagationTreeAnnotater | ||
| extends PropagationTreeAnnotator { | ||
| private class UniverseInferencePropagationTreeAnnotater extends PropagationTreeAnnotator { | ||
| public UniverseInferencePropagationTreeAnnotater(AnnotatedTypeFactory atypeFactory) { |
There was a problem hiding this comment.
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...
| boolean infer) { | ||
| super(checker, ichecker, factory, infer); | ||
|
|
||
| ANY = AnnotationBuilder.fromClass(elements, Any.class); |
There was a problem hiding this comment.
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.
| ((AnnotatedTypeMirror.AnnotatedExecutableType) type) | ||
| .getReturnType() | ||
| .addMissingAnnotations(Arrays.asList(UniverseAnnotationMirrorHolder.SELF)); | ||
| .addMissingAnnotations(Arrays.asList(atm.SELF)); |
There was a problem hiding this comment.
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.
You have a few casts like that, maybe add a field.
|
|
||
| if (AnnotationUtils.areSame(receiverAnnotation, SELF)) { | ||
| if (AnnotationUtils.areSame( | ||
| receiverAnnotation, ((UniverseAnnotatedTypeFactory) atypeFactory).SELF)) { |
There was a problem hiding this comment.
Same comment about extracting the casts by adding a field or even just a local variable here.
| Lattice lattice, Map<AnnotationMirror, Integer> typeToInt) { | ||
| super(lattice, typeToInt); | ||
| Set<AnnotationMirror> allTypes = typeToInt.keySet(); | ||
| for (AnnotationMirror am : allTypes) { |
Fixes #38