Skip to content

Commit

Permalink
add subtype constraint in Inference type Hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
txiang61 committed Mar 27, 2020
1 parent b823ab5 commit 4ce6043
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
21 changes: 21 additions & 0 deletions default.jaif
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package interning.qual:
annotation @UnknownInterned:

package interning.qual:
annotation @PolyInterned:

package interning.qual:
annotation @Interned:

package :
class MapAssignment:
field a:
insert-annotation Variable.type, ParameterizedType.type: @interning.qual.UnknownInterned

field b:
insert-annotation Variable.type, ParameterizedType.type: @interning.qual.UnknownInterned
insert-annotation Variable.type, ParameterizedType.typeArgument 1: @interning.qual.Interned

method <init>()V:


11 changes: 8 additions & 3 deletions src/checkers/inference/InferenceTypeHierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.checkerframework.framework.type.SubtypeVisitHistory;
import org.checkerframework.javacutil.BugInCF;

import javax.lang.model.element.AnnotationMirror;

import checkers.inference.model.Slot;

import javax.lang.model.element.AnnotationMirror;

/**
* The InferenceTypeHierarchy along with the InferenceQualifierHierarchy is responsible for
* creating a subtype and equality constraints. Normally the methods of these two classes are queried
Expand All @@ -27,7 +27,6 @@ public class InferenceTypeHierarchy extends DefaultTypeHierarchy {
private final AnnotationMirror varAnnot;
// TODO: Think this through, add any missing constraints


/**
* Constructs an instance of {@code TypeHierarchy} for the type system
* whose qualifiers represented in qualifierHierarchy.
Expand All @@ -52,6 +51,12 @@ public StructuralEqualityComparer createEqualityComparer() {
return new InferenceEqualityComparer(this.typeargVisitHistory,
InferenceQualifierHierarchy.findVarAnnot(qualifierHierarchy.getTopAnnotations()));
}

@Override
public boolean isSubtype(
final AnnotatedTypeMirror subtype, final AnnotatedTypeMirror supertype) {
return isSubtype(subtype, supertype, varAnnot);
}
}

class InferenceEqualityComparer extends StructuralEqualityComparer {
Expand Down

0 comments on commit 4ce6043

Please sign in to comment.