diff --git a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java index c4f9220..3189c55 100644 --- a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java +++ b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java @@ -21,6 +21,7 @@ import ontology.qual.OntologyValue; import ontology.util.OntologyUtils; import org.checkerframework.common.basetype.BaseAnnotatedTypeFactory; +import org.checkerframework.framework.qual.TypeUseLocation; import org.checkerframework.framework.type.AnnotatedTypeFactory; import org.checkerframework.framework.type.AnnotatedTypeMirror; import org.checkerframework.framework.type.QualifierHierarchy; @@ -28,6 +29,7 @@ import org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator; import org.checkerframework.framework.type.treeannotator.TreeAnnotator; import org.checkerframework.framework.util.MultiGraphQualifierHierarchy.MultiGraphFactory; +import org.checkerframework.framework.util.defaults.QualifierDefaults; public class OntologyInferenceAnnotatedTypeFactory extends InferenceAnnotatedTypeFactory { @@ -93,6 +95,17 @@ protected void finish( } } + /** + * TODO: Temporarily set the same default as in OntologyInferenceAnnotatedTypeFactory. Such a + * default should not be necessary in inference, but works around this CFI issue: + * https://github.com/opprop/checker-framework-inference/issues/310 + */ + @Override + protected void addCheckedCodeDefaults(QualifierDefaults defaults) { + TypeUseLocation[] topLocations = {TypeUseLocation.ALL}; + defaults.addCheckedCodeDefaults(OntologyUtils.ONTOLOGY_TOP, topLocations); + } + @Override public TreeAnnotator createTreeAnnotator() { return new ListTreeAnnotator( diff --git a/testing/ParameterizedTypeTest.java b/testing/ParameterizedTypeTest.java new file mode 100644 index 0000000..f191957 --- /dev/null +++ b/testing/ParameterizedTypeTest.java @@ -0,0 +1,17 @@ +interface Iterator { + T next(); +} + +abstract class CursorIterator implements Iterator { +} + +abstract class Matrix { + public void multiply1(CursorIterator it) { + double x = it.next(); + } + + public void multiply2(CursorIterator it) { + double x; + x = it.next(); + } +}