org.checkerframework.framework.util.typeinference.solver.InferredValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java's type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
package org.checkerframework.framework.util.typeinference.solver;
import java.util.Collection;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.type.TypeVariable;
import org.checkerframework.framework.type.AnnotatedTypeMirror;
import org.checkerframework.framework.util.AnnotationMirrorSet;
/**
* When one of the constraint solvers infers that a the target has a given type/target in ALL
* qualifier hierarchies or that given an additional set of annotations that we know the target must
* hold we have covered all hierarchies then it creates an InferredValue to represent this
* inference.
*
* There are subclasses to represent two cases:
*
*
* - The target was inferred to be an AnnotatedTypeMirror
*
- The target was inferred to be equal to another target
*
*/
public class InferredValue {
/**
* Indicates that a corresponding target was inferred to be the field "type" in all hierarchies.
*/
public static class InferredType extends InferredValue {
public final AnnotatedTypeMirror type;
public InferredType(final AnnotatedTypeMirror type) {
this.type = type;
}
}
/**
* Indicates that a corresponding target was inferred to be the field "target" in the hierarchies
* not overridden by additionalAnnotations.
*/
public static class InferredTarget extends InferredValue {
public final TypeVariable target;
/**
* Indicates that the inferred type should have these primary annotations and the remainder
* should come from the annotations inferred for target.
*/
public final AnnotationMirrorSet additionalAnnotations;
public InferredTarget(
final TypeVariable target,
final Collection additionalAnnotations) {
this.target = target;
this.additionalAnnotations = new AnnotationMirrorSet(additionalAnnotations);
}
}
}