From 95c57d66e139432297889b48c62bf3cffcb154b8 Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Sun, 28 Jul 2019 02:51:16 +0100 Subject: [PATCH] Handle one more special case. Fixes #216. --- annotation-file-utilities/src/annotator/find/TreeFinder.java | 4 ++++ annotation-file-utilities/tests/Issue216.goal | 3 ++- annotation-file-utilities/tests/Issue216.jaif | 2 -- annotation-file-utilities/tests/Issue216.java | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/annotation-file-utilities/src/annotator/find/TreeFinder.java b/annotation-file-utilities/src/annotator/find/TreeFinder.java index 9e0097911..f3308e08c 100644 --- a/annotation-file-utilities/src/annotator/find/TreeFinder.java +++ b/annotation-file-utilities/src/annotator/find/TreeFinder.java @@ -1054,6 +1054,10 @@ public Void scan(Tree node, List p) { if (parentKind == Tree.Kind.NEW_CLASS) { continue; } + IdentifierTree id = (IdentifierTree) node; + if (id.getName().contentEquals("this")) { + continue; + } break; default: // TODO: make this switch statement exhaustive and check each case. diff --git a/annotation-file-utilities/tests/Issue216.goal b/annotation-file-utilities/tests/Issue216.goal index 8c7eb3d0c..bb21662aa 100644 --- a/annotation-file-utilities/tests/Issue216.goal +++ b/annotation-file-utilities/tests/Issue216.goal @@ -1,7 +1,8 @@ -class Issue216 { +public class Issue216 { Object value; Object value2 = new Object(); + Issue216 t = this; @org.checkerframework.dataflow.qual.SideEffectFree public Issue216() {} diff --git a/annotation-file-utilities/tests/Issue216.jaif b/annotation-file-utilities/tests/Issue216.jaif index 04e3ee670..917ec908c 100644 --- a/annotation-file-utilities/tests/Issue216.jaif +++ b/annotation-file-utilities/tests/Issue216.jaif @@ -4,7 +4,5 @@ annotation @SideEffectFree: @java.lang.annotation.Retention(value=RUNTIME) @java package : class Issue216: - field value: - method ()V: @org.checkerframework.dataflow.qual.SideEffectFree return: diff --git a/annotation-file-utilities/tests/Issue216.java b/annotation-file-utilities/tests/Issue216.java index 5418fc431..223c692c4 100644 --- a/annotation-file-utilities/tests/Issue216.java +++ b/annotation-file-utilities/tests/Issue216.java @@ -1,7 +1,8 @@ -class Issue216 { +public class Issue216 { Object value; Object value2 = new Object(); + Issue216 t = this; public Issue216() {} }