Skip to content

Commit

Permalink
Fix for feature request typetools#3313 in Aliasing Checker
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya3434 committed Jun 5, 2020
1 parent 4ecaa4c commit 22462e0
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
}
}
Expand All @@ -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() {
Expand Down

0 comments on commit 22462e0

Please sign in to comment.