Skip to content

Commit

Permalink
Clean up inference code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ao-senXiong committed May 15, 2024
1 parent f28c591 commit 8eb5c37
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions src/main/java/pico/inference/PICOInferenceVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.sun.source.tree.UnaryTree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePath;
import org.checkerframework.checker.compilermsgs.qual.CompilerMessageKey;
import org.checkerframework.common.basetype.BaseAnnotatedTypeFactory;
import org.checkerframework.framework.type.AnnotatedTypeFactory.ParameterizedExecutableType;
import org.checkerframework.framework.type.AnnotatedTypeMirror;
Expand All @@ -38,7 +37,6 @@
import pico.common.ExtendedViewpointAdapter;
import pico.common.ViewpointAdapterGettable;
import pico.common.PICOTypeUtil;
import qual.ReceiverDependantMutable;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
Expand All @@ -50,11 +48,8 @@
import javax.lang.model.type.TypeMirror;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static pico.typecheck.PICOAnnotationMirrorHolder.*;

Expand Down Expand Up @@ -204,57 +199,6 @@ private void addMutableImmutableRdmIncompatibleConstraints(AnnotatedDeclaredType
constraintManager.addImplicationConstraint(Arrays.asList(isImmutable), notRDM);
}

// @Override
// public boolean validateTypeOf(Tree tree) {
// AnnotatedTypeMirror type;
// // It's quite annoying that there is no TypeTree
// switch (tree.getKind()) {
// case PRIMITIVE_TYPE:
// case PARAMETERIZED_TYPE:
// case TYPE_PARAMETER:
// case ARRAY_TYPE:
// case UNBOUNDED_WILDCARD:
// case EXTENDS_WILDCARD:
// case SUPER_WILDCARD:
// case ANNOTATED_TYPE:
// type = atypeFactory.getAnnotatedTypeFromTypeTree(tree);
// break;
// case METHOD:
// type = atypeFactory.getMethodReturnType((MethodTree) tree);
// if (type == null ||
// type.getKind() == TypeKind.VOID) {
// // Nothing to do for void methods.
// // Note that for a constructor the AnnotatedExecutableType does
// // not use void as return type.
// return true;
// }
// break;
// default:
// type = atypeFactory.getAnnotatedType(tree);
// }
//
// return validateType(tree, type);
// // extends clause kind = IDENTIFIER. an annotator is added for defaulting
// }

// // TODO This might not be correct for infer mode. Maybe returning as it is
// @Override
// public boolean validateType(Tree tree, AnnotatedTypeMirror type) {
//
// if (!typeValidator.isValid(type, tree)) { // in inference, isValid never return false
// return false;
// }
// // The initial purpose of always returning true in validateTypeOf in inference mode
// // might be that inference we want to generate constraints over all the ast location,
// // but not like in typechecking mode, if something is not valid, we abort checking the
// // remaining parts that are based on the invalid type. For example, in assignment, if
// // rhs is not valid, we don't check the validity of assignment. But in inference,
// // we always generate constraints on all places and let solver to decide if there is
// // solution or not. This might be the reason why we have a always true if statement and
// // validity check always returns true.
// return true;
// }

@Override
protected void checkConstructorInvocation(AnnotatedDeclaredType invocation, AnnotatedExecutableType constructor, NewClassTree newClassTree) {
AnnotationMirror constructorReturn = extractVarAnnot(constructor.getReturnType());
Expand Down Expand Up @@ -1050,7 +994,6 @@ private void checkAnonymousImplements(ClassTree node, AnnotatedDeclaredType boun
}
}


/**
* extends/implements clause use anno is adapted subtype of bound anno
* <p> Could be subtype, but recall Readonly and Bottom is not usable on class init bound.</p>
Expand All @@ -1068,7 +1011,6 @@ private void checkSuperClauseEquals(ClassTree node, AnnotatedDeclaredType bound)
}
}


private void boundVsExtImpClause(AnnotatedDeclaredType classBound, AnnotatedTypeMirror superType, String errorKey, Tree tree) {
// atypeFactory.getTypeDeclarationBounds does not work correctly: getting the real annos instead of slots
AnnotatedTypeMirror superBound =
Expand All @@ -1082,19 +1024,6 @@ private void boundVsExtImpClause(AnnotatedDeclaredType classBound, AnnotatedType
isAdaptedSubtype(classBound, superType, errorKey, tree);
}


// private boolean checkCompatabilityBetweenBoundAndSuperClassesBounds(ClassTree node, TypeElement typeElement, AnnotatedDeclaredType bound) {
// // Must have compatible bound annotation as the direct super types
// List<AnnotatedDeclaredType> superBounds = PICOTypeUtil.getBoundTypesOfDirectSuperTypes(typeElement, atypeFactory);
// for (AnnotatedDeclaredType superBound : superBounds) {
// if (!isAdaptedSubtype(bound, superBound)) {
// checker.reportError(node, "subclass.bound.incompatible", bound, superBound);
// return false; // do not stop processing if failed
// }
// }
// return true;
// }

/**
* commonAssignmentCheck() method that adapts to PICOInfer.
*
Expand Down

0 comments on commit 8eb5c37

Please sign in to comment.