Skip to content

Remove mirror holder#100

Open
aosen-xiong wants to merge 4 commits into
masterfrom
refactor
Open

Remove mirror holder#100
aosen-xiong wants to merge 4 commits into
masterfrom
refactor

Conversation

@aosen-xiong

Copy link
Copy Markdown
Contributor

Fixes #38

@wmdietl wmdietl left a comment

Copy link
Copy Markdown
Member

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!

Comment thread src/main/java/universe/UniverseAnnotatedTypeFactory.java
Comment thread src/main/java/universe/UniverseInferenceAnnotatedTypeFactory.java
Comment thread src/main/java/universe/UniverseInferenceAnnotatedTypeFactory.java
private static class UniverseInferencePropagationTreeAnnotater
extends PropagationTreeAnnotator {
private class UniverseInferencePropagationTreeAnnotater extends PropagationTreeAnnotator {
public UniverseInferencePropagationTreeAnnotater(AnnotatedTypeFactory atypeFactory) {

Copy link
Copy Markdown
Member

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...

Comment thread src/main/java/universe/UniverseInferenceValidator.java
boolean infer) {
super(checker, ichecker, factory, infer);

ANY = AnnotationBuilder.fromClass(elements, Any.class);

Copy link
Copy Markdown
Member

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.

((AnnotatedTypeMirror.AnnotatedExecutableType) type)
.getReturnType()
.addMissingAnnotations(Arrays.asList(UniverseAnnotationMirrorHolder.SELF));
.addMissingAnnotations(Arrays.asList(atm.SELF));

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Member

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.


if (AnnotationUtils.areSame(receiverAnnotation, SELF)) {
if (AnnotationUtils.areSame(
receiverAnnotation, ((UniverseAnnotatedTypeFactory) atypeFactory).SELF)) {

Copy link
Copy Markdown
Member

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.

Lattice lattice, Map<AnnotationMirror, Integer> typeToInt) {
super(lattice, typeToInt);
Set<AnnotationMirror> allTypes = typeToInt.keySet();
for (AnnotationMirror am : allTypes) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this doing?

@wmdietl wmdietl assigned aosen-xiong and unassigned wmdietl Jun 28, 2024
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.

Lattice class cleanup

2 participants