From 85075d032c9ee21e488017fb94642e6386122a63 Mon Sep 17 00:00:00 2001 From: lnsun <57457122+lnsun@users.noreply.github.com> Date: Mon, 18 Jan 2021 20:47:32 -0500 Subject: [PATCH] handle jaif for constructor with empty ASTPath incl. Zhou's fixes --- src/checkers/inference/util/ASTPathUtil.java | 6 +++++- src/checkers/inference/util/JaifBuilder.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/checkers/inference/util/ASTPathUtil.java b/src/checkers/inference/util/ASTPathUtil.java index bbf59bcfc..1e95208db 100644 --- a/src/checkers/inference/util/ASTPathUtil.java +++ b/src/checkers/inference/util/ASTPathUtil.java @@ -74,7 +74,11 @@ public static ASTRecord getASTRecordForPath(final AnnotatedTypeFactory typeFacto * this class. */ public static ASTRecord getConstructorRecord(ASTRecord classRecord) { - return new ASTRecord(classRecord.ast, classRecord.className, AFU_CONSTRUCTOR_ID, null, ASTPath.empty()); + return new ASTRecord(classRecord.ast, classRecord.className, AFU_CONSTRUCTOR_ID, null, getMethodTypeASTPath()); + } + + public static ASTPath getMethodTypeASTPath() { + return ASTPath.empty().extend(new ASTPath.ASTEntry(Tree.Kind.METHOD, ASTPath.TYPE, null)); } /** diff --git a/src/checkers/inference/util/JaifBuilder.java b/src/checkers/inference/util/JaifBuilder.java index 8b3018346..f6a4138bb 100644 --- a/src/checkers/inference/util/JaifBuilder.java +++ b/src/checkers/inference/util/JaifBuilder.java @@ -310,7 +310,12 @@ private void buildClassEntries() { // TODO: this is not a feature but a workaround of a bug: // We should create a non-empty correct ASTPath for constructor if (astRecord.astPath.equals(ASTPath.empty())) { - continue; + if (astRecord.methodName != null && astRecord.methodName.contains("")) { + astRecord = new ASTRecord(astRecord.ast, astRecord.className, + astRecord.methodName, astRecord.varName, ASTPathUtil.getMethodTypeASTPath()); + } else { + continue; + } } memberRecords.entries.add(new RecordValue(astRecord.astPath,annotation));