Skip to content

Commit 4ce6043

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

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import org.checkerframework.framework.type.SubtypeVisitHistory;
1010
import org.checkerframework.javacutil.BugInCF;
1111

12-
import javax.lang.model.element.AnnotationMirror;
13-
1412
import checkers.inference.model.Slot;
1513

14+
import javax.lang.model.element.AnnotationMirror;
15+
1616
/**
1717
* The InferenceTypeHierarchy along with the InferenceQualifierHierarchy is responsible for
1818
* creating a subtype and equality constraints. Normally the methods of these two classes are queried
@@ -27,7 +27,6 @@ public class InferenceTypeHierarchy extends DefaultTypeHierarchy {
2727
private final AnnotationMirror varAnnot;
2828
// TODO: Think this through, add any missing constraints
2929

30-
3130
/**
3231
* Constructs an instance of {@code TypeHierarchy} for the type system
3332
* whose qualifiers represented in qualifierHierarchy.
@@ -52,6 +51,12 @@ public StructuralEqualityComparer createEqualityComparer() {
5251
return new InferenceEqualityComparer(this.typeargVisitHistory,
5352
InferenceQualifierHierarchy.findVarAnnot(qualifierHierarchy.getTopAnnotations()));
5453
}
54+
55+
@Override
56+
public boolean isSubtype(
57+
final AnnotatedTypeMirror subtype, final AnnotatedTypeMirror supertype) {
58+
return isSubtype(subtype, supertype, varAnnot);
59+
}
5560
}
5661

5762
class InferenceEqualityComparer extends StructuralEqualityComparer {

0 commit comments

Comments
 (0)