From fab61bdfcac253e613195320109f7d7567690cb5 Mon Sep 17 00:00:00 2001 From: d367wang Date: Mon, 15 Mar 2021 03:08:48 +0000 Subject: [PATCH 1/8] walkaround for ontology crashing on parameterized test --- .../OntologyInferenceAnnotatedTypeFactory.java | 8 ++++++++ testing/ParameterizedTypeTest.java | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 testing/ParameterizedTypeTest.java diff --git a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java index c4f9220..57a8f6d 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,12 @@ protected void finish( } } + @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..04b69d1 --- /dev/null +++ b/testing/ParameterizedTypeTest.java @@ -0,0 +1,13 @@ +interface Iterator { + T next(); +} + +abstract class CursorIterator implements Iterator { +} + +abstract class Matrix { + public void multiply(CursorIterator it) { + double x; + x = it.next(); + } +} \ No newline at end of file From 3843ff9ec679fe8b716e335995f75f61db12612e Mon Sep 17 00:00:00 2001 From: d367wang Date: Mon, 15 Mar 2021 03:49:21 +0000 Subject: [PATCH 2/8] add comment --- src/ontology/OntologyInferenceAnnotatedTypeFactory.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java index 57a8f6d..abb5583 100644 --- a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java +++ b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java @@ -95,6 +95,14 @@ protected void finish( } } + /** + * This copies the same overriding in OntologyInferenceAnnotatedTypeFactory, just to + * walk around the crash happening in CFI continious integration, by setting default + * qualifier for type inference. Such that any type use always has an annotation, + * which avoid constraints like `@VarAnnot(?) = null` + * TODO: need to eliminate this overriding by solving the issue: + * https://github.com/opprop/checker-framework-inference/issues/310 + */ @Override protected void addCheckedCodeDefaults(QualifierDefaults defaults) { TypeUseLocation[] topLocations = {TypeUseLocation.ALL}; From 46a0334e8e6b71cdb194be67131b22f864cb866a Mon Sep 17 00:00:00 2001 From: d367wang Date: Mon, 15 Mar 2021 04:03:20 +0000 Subject: [PATCH 3/8] reformat --- src/ontology/OntologyInferenceAnnotatedTypeFactory.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java index abb5583..becf250 100644 --- a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java +++ b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java @@ -96,11 +96,10 @@ protected void finish( } /** - * This copies the same overriding in OntologyInferenceAnnotatedTypeFactory, just to - * walk around the crash happening in CFI continious integration, by setting default - * qualifier for type inference. Such that any type use always has an annotation, - * which avoid constraints like `@VarAnnot(?) = null` - * TODO: need to eliminate this overriding by solving the issue: + * This copies the same overriding in OntologyInferenceAnnotatedTypeFactory, just to walk around + * the crash happening in CFI continious integration, by setting default qualifier for type + * inference. Such that any type use always has an annotation, which avoid constraints like + * `@VarAnnot(?) = null` TODO: need to eliminate this overriding by solving the issue: * https://github.com/opprop/checker-framework-inference/issues/310 */ @Override From e97acf3ecaa5eb391bf1789b814d576dc927c261 Mon Sep 17 00:00:00 2001 From: Weitian Xing Date: Mon, 15 Mar 2021 00:12:52 -0400 Subject: [PATCH 4/8] Update ParameterizedTypeTest.java --- testing/ParameterizedTypeTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/ParameterizedTypeTest.java b/testing/ParameterizedTypeTest.java index 04b69d1..01fbd0e 100644 --- a/testing/ParameterizedTypeTest.java +++ b/testing/ParameterizedTypeTest.java @@ -10,4 +10,4 @@ public void multiply(CursorIterator it) { double x; x = it.next(); } -} \ No newline at end of file +} From 12edfd1de50ad8066a46d154636e1cad2afc50f5 Mon Sep 17 00:00:00 2001 From: d367wang <55197967+d367wang@users.noreply.github.com> Date: Mon, 15 Mar 2021 00:58:47 -0400 Subject: [PATCH 5/8] fix typo --- src/ontology/OntologyInferenceAnnotatedTypeFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java index becf250..a4a1d73 100644 --- a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java +++ b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java @@ -96,9 +96,9 @@ protected void finish( } /** - * This copies the same overriding in OntologyInferenceAnnotatedTypeFactory, just to walk around - * the crash happening in CFI continious integration, by setting default qualifier for type - * inference. Such that any type use always has an annotation, which avoid constraints like + * This copies the same overriding in OntologyInferenceAnnotatedTypeFactory, just to work around + * the crash happening during CFI continuous integration, by setting default qualifier for type + * inference. Such that any type use always has an annotation, which avoids constraints like * `@VarAnnot(?) = null` TODO: need to eliminate this overriding by solving the issue: * https://github.com/opprop/checker-framework-inference/issues/310 */ From 56e5ba35e81a20eab287155961e49ab118ca7158 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Mon, 15 Mar 2021 13:58:13 -0400 Subject: [PATCH 6/8] Shorten text. --- src/ontology/OntologyInferenceAnnotatedTypeFactory.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java index a4a1d73..a2b1cf1 100644 --- a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java +++ b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java @@ -96,10 +96,8 @@ protected void finish( } /** - * This copies the same overriding in OntologyInferenceAnnotatedTypeFactory, just to work around - * the crash happening during CFI continuous integration, by setting default qualifier for type - * inference. Such that any type use always has an annotation, which avoids constraints like - * `@VarAnnot(?) = null` TODO: need to eliminate this overriding by solving the issue: + * 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 From f1482f50d773afc60b1a59235bf612cdc41cb5e6 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Mon, 15 Mar 2021 14:03:51 -0400 Subject: [PATCH 7/8] Include both styles of initialization. --- testing/ParameterizedTypeTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/testing/ParameterizedTypeTest.java b/testing/ParameterizedTypeTest.java index 01fbd0e..f191957 100644 --- a/testing/ParameterizedTypeTest.java +++ b/testing/ParameterizedTypeTest.java @@ -6,7 +6,11 @@ abstract class CursorIterator implements Iterator { } abstract class Matrix { - public void multiply(CursorIterator it) { + public void multiply1(CursorIterator it) { + double x = it.next(); + } + + public void multiply2(CursorIterator it) { double x; x = it.next(); } From 53cd621ff70cbd53cf60a23e0defa425e9c81e9b Mon Sep 17 00:00:00 2001 From: d367wang Date: Mon, 15 Mar 2021 18:18:38 +0000 Subject: [PATCH 8/8] reformat --- src/ontology/OntologyInferenceAnnotatedTypeFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java index a2b1cf1..3189c55 100644 --- a/src/ontology/OntologyInferenceAnnotatedTypeFactory.java +++ b/src/ontology/OntologyInferenceAnnotatedTypeFactory.java @@ -96,8 +96,8 @@ 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: + * 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