Search in sources :

Example 1 with AnnotationMirrorSet

use of org.checkerframework.framework.util.AnnotationMirrorSet in project checker-framework by typetools.

the class ConstraintMap method addTargetSubtype.

/**
 * Add a constraint indicating that target is a subtype of supertype in the given qualifier
 * hierarchies.
 *
 * @param hierarchies a set of TOP annotations
 */
public void addTargetSubtype(final TypeVariable target, final TypeVariable supertype, AnnotationMirrorSet hierarchies) {
    final Subtypes subtypes = targetToRecords.get(target).subtypes;
    final AnnotationMirrorSet subtypesTops = subtypes.targets.computeIfAbsent(supertype, __ -> new AnnotationMirrorSet());
    subtypesTops.addAll(hierarchies);
}
Also used : Subtypes(org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Subtypes) AnnotationMirrorSet(org.checkerframework.framework.util.AnnotationMirrorSet)

Example 2 with AnnotationMirrorSet

use of org.checkerframework.framework.util.AnnotationMirrorSet in project checker-framework by typetools.

the class ConstraintMap method addTargetEquality.

/**
 * Add a constraint indicating that the equivalent is equal to target in the given qualifier
 * hierarchies.
 */
public void addTargetEquality(final TypeVariable target, final TypeVariable equivalent, AnnotationMirrorSet hierarchies) {
    final Equalities equalities = targetToRecords.get(target).equalities;
    final AnnotationMirrorSet equivalentTops = equalities.targets.computeIfAbsent(equivalent, __ -> new AnnotationMirrorSet());
    equivalentTops.addAll(hierarchies);
}
Also used : Equalities(org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Equalities) AnnotationMirrorSet(org.checkerframework.framework.util.AnnotationMirrorSet)

Example 3 with AnnotationMirrorSet

use of org.checkerframework.framework.util.AnnotationMirrorSet in project checker-framework by typetools.

the class ConstraintMap method addTypeSupertype.

/**
 * Add a constraint indicating that target is a supertype of subtype in the given qualifier
 * hierarchies.
 *
 * @param hierarchies a set of TOP annotations
 */
public void addTypeSupertype(final TypeVariable target, final AnnotatedTypeMirror subtype, AnnotationMirrorSet hierarchies) {
    final Supertypes supertypes = targetToRecords.get(target).supertypes;
    final AnnotationMirrorSet supertypeTops = supertypes.types.computeIfAbsent(subtype, __ -> new AnnotationMirrorSet());
    supertypeTops.addAll(hierarchies);
}
Also used : AnnotationMirrorSet(org.checkerframework.framework.util.AnnotationMirrorSet) Supertypes(org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Supertypes)

Example 4 with AnnotationMirrorSet

use of org.checkerframework.framework.util.AnnotationMirrorSet in project checker-framework by typetools.

the class ConstraintMap method addTypeSubtype.

/**
 * Add a constraint indicating that target is a subtype of supertype in the given qualifier
 * hierarchies.
 *
 * @param hierarchies a set of TOP annotations
 */
public void addTypeSubtype(final TypeVariable target, final AnnotatedTypeMirror supertype, AnnotationMirrorSet hierarchies) {
    final Subtypes subtypes = targetToRecords.get(target).subtypes;
    final AnnotationMirrorSet subtypesTops = subtypes.types.computeIfAbsent(supertype, __ -> new AnnotationMirrorSet());
    subtypesTops.addAll(hierarchies);
}
Also used : Subtypes(org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Subtypes) AnnotationMirrorSet(org.checkerframework.framework.util.AnnotationMirrorSet)

Example 5 with AnnotationMirrorSet

use of org.checkerframework.framework.util.AnnotationMirrorSet in project checker-framework by typetools.

the class ConstraintMap method addPrimarySubtypes.

/**
 * Add a constraint indicating that target's primary annotations are subtypes of the given
 * annotations.
 */
public void addPrimarySubtypes(final TypeVariable target, QualifierHierarchy qualifierHierarchy, final AnnotationMirrorSet annos) {
    final Subtypes subtypes = targetToRecords.get(target).subtypes;
    for (final AnnotationMirror anno : annos) {
        final AnnotationMirror top = qualifierHierarchy.getTopAnnotation(anno);
        AnnotationMirrorSet entries = subtypes.primaries.computeIfAbsent(top, __ -> new AnnotationMirrorSet());
        entries.add(anno);
    }
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) Subtypes(org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Subtypes) AnnotationMirrorSet(org.checkerframework.framework.util.AnnotationMirrorSet)

Aggregations

AnnotationMirrorSet (org.checkerframework.framework.util.AnnotationMirrorSet)29 AnnotatedTypeMirror (org.checkerframework.framework.type.AnnotatedTypeMirror)17 AnnotationMirror (javax.lang.model.element.AnnotationMirror)16 AnnotationMirrorMap (org.checkerframework.framework.util.AnnotationMirrorMap)12 Map (java.util.Map)11 LinkedHashMap (java.util.LinkedHashMap)8 TypeVariable (javax.lang.model.type.TypeVariable)8 AnnotatedTypeVariable (org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedTypeVariable)8 InferredType (org.checkerframework.framework.util.typeinference.solver.InferredValue.InferredType)8 QualifierHierarchy (org.checkerframework.framework.type.QualifierHierarchy)6 Equalities (org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Equalities)4 Subtypes (org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Subtypes)4 ArrayList (java.util.ArrayList)3 Supertypes (org.checkerframework.framework.util.typeinference.solver.TargetConstraints.Supertypes)3 BugInCF (org.checkerframework.javacutil.BugInCF)3 Types (javax.lang.model.util.Types)2 Entry (java.util.Map.Entry)1 DeclaredType (javax.lang.model.type.DeclaredType)1 AnnotatedPrimitiveType (org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedPrimitiveType)1 TypeHierarchy (org.checkerframework.framework.type.TypeHierarchy)1