Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for ontology crashing on parameterized test #49

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/ontology/OntologyInferenceAnnotatedTypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
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;
import org.checkerframework.framework.type.treeannotator.ListTreeAnnotator;
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 {

Expand Down Expand Up @@ -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(
Expand Down
17 changes: 17 additions & 0 deletions testing/ParameterizedTypeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interface Iterator<T> {
T next();
}

abstract class CursorIterator implements Iterator<Double> {
}

abstract class Matrix {
public void multiply1(CursorIterator it) {
double x = it.next();
}

public void multiply2(CursorIterator it) {
double x;
x = it.next();
}
}