From 22462e0c3106a97353ababcbcb9c547d061f9809 Mon Sep 17 00:00:00 2001 From: aditya3434 Date: Tue, 26 May 2020 23:24:31 +0530 Subject: [PATCH] Fix for feature request #3313 in Aliasing Checker --- .../checkerframework/common/aliasing/AliasingVisitor.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/src/main/java/org/checkerframework/common/aliasing/AliasingVisitor.java b/framework/src/main/java/org/checkerframework/common/aliasing/AliasingVisitor.java index 63d7ba5678a..ae19becda68 100644 --- a/framework/src/main/java/org/checkerframework/common/aliasing/AliasingVisitor.java +++ b/framework/src/main/java/org/checkerframework/common/aliasing/AliasingVisitor.java @@ -70,7 +70,8 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void p) { // Check if a call to super() might create an alias: that // happens when the parent's respective constructor is not @Unique. AnnotatedTypeMirror superResult = atypeFactory.getAnnotatedType(node); - if (!superResult.hasAnnotation(Unique.class)) { + if ((!superResult.hasAnnotation(Unique.class)) + && (!superResult.toString().equals("@MaybeAliased Object"))) { checker.reportError(node, "unique.leaked"); } } else { @@ -255,7 +256,8 @@ protected void checkThisOrSuperConstructorCall( // Check if a call to super() might create an alias: that // happens when the parent's respective constructor is not @Unique. AnnotatedTypeMirror superResult = atypeFactory.getAnnotatedType(superCall); - if (!superResult.hasAnnotation(Unique.class)) { + if ((!superResult.hasAnnotation(Unique.class)) + && (!superResult.toString().equals("@MaybeAliased Object"))) { checker.reportError(superCall, "unique.leaked"); } } @@ -271,7 +273,7 @@ private boolean canBeLeaked(Tree exp) { AnnotatedTypeMirror type = atypeFactory.getAnnotatedType(exp); boolean isMethodInvocation = exp.getKind() == Kind.METHOD_INVOCATION; boolean isNewClass = exp.getKind() == Kind.NEW_CLASS; - return type.hasExplicitAnnotation(Unique.class) && !isMethodInvocation && !isNewClass; + return type.hasAnnotation(Unique.class) && !isMethodInvocation && !isNewClass; } private boolean isInUniqueConstructor() {