Skip to content

Commit

Permalink
Cleaner logic to handle types of extends and implements clauses and f…
Browse files Browse the repository at this point in the history
…ixed `getTypeOfExtendsImplements` (opprop#134)
  • Loading branch information
piyush-J authored Jan 7, 2022
1 parent 8339331 commit 9e44da6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/manual/contributors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
Paul Vines,
Paulo Barros,
Philip Lai,
Piyush Jha,
Prionti Nasir,
Priti Chattopadhyay,
Rashmi Mudduluru,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,25 +526,15 @@ public void processClassTree(ClassTree classTree) {

Tree ext = classTree.getExtendsClause();
if (ext != null) {
for (AnnotatedDeclaredType superType : classType.directSupertypes()) {
if (superType.getUnderlyingType().asElement().getKind().isClass()) {
validateType(ext, superType);
break;
}
}
AnnotatedTypeMirror superClass = atypeFactory.getTypeOfExtendsImplements(ext);
validateType(ext, superClass);
}

List<? extends Tree> impls = classTree.getImplementsClause();
if (impls != null) {
for (Tree im : impls) {
for (AnnotatedDeclaredType superType : classType.directSupertypes()) {
if (superType.getUnderlyingType().asElement().getKind().isInterface()
&& types.isSameType(
superType.getUnderlyingType(), TreeUtils.typeOf(im))) {
validateType(im, superType);
break;
}
}
AnnotatedTypeMirror superInterface = atypeFactory.getTypeOfExtendsImplements(im);
validateType(im, superInterface);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ public AnnotatedTypeMirror getTypeOfExtendsImplements(Tree clause) {
AnnotatedTypeMirror fromTypeTree = fromTypeTree(clause);
Set<AnnotationMirror> bound = getTypeDeclarationBounds(fromTypeTree.getUnderlyingType());
fromTypeTree.addMissingAnnotations(bound);
addComputedTypeAnnotations(clause, fromTypeTree);
return fromTypeTree;
}

Expand Down

0 comments on commit 9e44da6

Please sign in to comment.