Skip to content

Commit b687b37

Browse files
committed
add subtype constraint in Inference type Hierarchy
1 parent b823ab5 commit b687b37

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

default.jaif

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package interning.qual:
2+
annotation @UnknownInterned:
3+
4+
package interning.qual:
5+
annotation @PolyInterned:
6+
7+
package interning.qual:
8+
annotation @Interned:
9+
10+
package :
11+
class MapAssignment:
12+
field a:
13+
insert-annotation Variable.type, ParameterizedType.type: @interning.qual.UnknownInterned
14+
15+
field b:
16+
insert-annotation Variable.type, ParameterizedType.type: @interning.qual.UnknownInterned
17+
insert-annotation Variable.type, ParameterizedType.typeArgument 1: @interning.qual.Interned
18+
19+
method <init>()V:
20+
21+

src/checkers/inference/InferenceTypeHierarchy.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
import org.checkerframework.framework.type.StructuralEqualityComparer;
88
import org.checkerframework.framework.type.StructuralEqualityVisitHistory;
99
import org.checkerframework.framework.type.SubtypeVisitHistory;
10+
import org.checkerframework.javacutil.AnnotationUtils;
1011
import org.checkerframework.javacutil.BugInCF;
1112

1213
import javax.lang.model.element.AnnotationMirror;
1314

14-
import checkers.inference.model.Slot;
15-
1615
/**
1716
* The InferenceTypeHierarchy along with the InferenceQualifierHierarchy is responsible for
1817
* creating a subtype and equality constraints. Normally the methods of these two classes are queried
@@ -27,7 +26,6 @@ public class InferenceTypeHierarchy extends DefaultTypeHierarchy {
2726
private final AnnotationMirror varAnnot;
2827
// TODO: Think this through, add any missing constraints
2928

30-
3129
/**
3230
* Constructs an instance of {@code TypeHierarchy} for the type system
3331
* whose qualifiers represented in qualifierHierarchy.
@@ -52,6 +50,12 @@ public StructuralEqualityComparer createEqualityComparer() {
5250
return new InferenceEqualityComparer(this.typeargVisitHistory,
5351
InferenceQualifierHierarchy.findVarAnnot(qualifierHierarchy.getTopAnnotations()));
5452
}
53+
54+
@Override
55+
public boolean isSubtype(
56+
final AnnotatedTypeMirror subtype, final AnnotatedTypeMirror supertype) {
57+
return isSubtype(subtype, supertype, varAnnot);
58+
}
5559
}
5660

5761
class InferenceEqualityComparer extends StructuralEqualityComparer {

0 commit comments

Comments
 (0)