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

Duplicate element ATM before get/put #362

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/checkers/inference/VariableAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ private void addExistentialVariable(final AnnotatedTypeVariable typeVar, final T
// TODO: THIS CRASHES ON RECURSIVE TYPES
typeVarDecl = inferenceTypeFactory.getAnnotatedType(typeVarDeclElem);
} else {
typeVarDecl = elementToAtm.get(typeVarDeclElem);
typeVarDecl = elementToAtm.get(typeVarDeclElem).deepCopy();
// TODO: I THINK THIS IS UNNECESSARY DUE TO InferenceVisitor.visitVariable
// if(tree instanceof VariableTree && !treeToVariable.containsKey(tree)) { // if it's a declaration of a variable, store it
// final Element varElement = TreeUtils.elementFromDeclaration((VariableTree) tree);
Expand Down Expand Up @@ -599,7 +599,8 @@ public ConstantSlot getTopConstant() {
* @see checkers.inference.VariableAnnotator#annotateElementFromStore
*/
public void storeElementType(final Element element, final AnnotatedTypeMirror atm) {
elementToAtm.put(element, atm);
final AnnotatedTypeMirror copy = atm.deepCopy();
elementToAtm.put(element, copy);
}

/**
Expand Down Expand Up @@ -1204,10 +1205,6 @@ public Void visitTypeVariable(AnnotatedTypeVariable typeVar, Tree tree) {
final TypeParameterElement typeParamElement = (TypeParameterElement) typeVar.getUnderlyingType().asElement();
final TypeParameterTree typeParameterTree = (TypeParameterTree) tree;

if (!elementToAtm.containsKey(typeParamElement)) {
storeElementType(typeParamElement, typeVar);
}

// add lower bound annotation
addPrimaryVariable(typeVar.getLowerBound(), tree);

Expand Down Expand Up @@ -1252,6 +1249,11 @@ public Void visitTypeVariable(AnnotatedTypeVariable typeVar, Tree tree) {
upperBound.addAnnotation(slotManager.getAnnotation(extendsSlot));
}

if (!elementToAtm.containsKey(typeParamElement)) {
// cache the element ATM when it's fully annotated
storeElementType(typeParamElement, typeVar);
}

} else {

addExistentialVariable(typeVar, tree, false);
Expand Down