All Downloads are FREE. Search and download functionalities are using the official Maven repository.

framework.src.org.checkerframework.framework.util.typeinference.solver.InferredValue Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.42.0
Show newest version
package org.checkerframework.framework.util.typeinference.solver;

import org.checkerframework.framework.type.AnnotatedTypeMirror;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.type.TypeVariable;

/**
 * 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:
 *   a) The target was inferred to be an AnnotatedTypeMirror
 *   b) 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 Set additionalAnnotations;

        public InferredTarget(final TypeVariable target,
                              final Collection additionalAnnotations) {
            this.target = target;
            this.additionalAnnotations = new HashSet<>(additionalAnnotations);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy