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` (#6862)

Co-authored-by: Piyush Jha <piyushnit15@gmail.com>
  • Loading branch information
mernst and piyush-J authored Oct 18, 2024
1 parent e7f249e commit 19419ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/manual/contributors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
Paul Vines,
Paulo Barros,
Philip Lai,
Piyush Jha,
Pratik Bhusal,
Prionti Nasir,
Priti Chattopadhyay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,24 +582,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 @@ -1518,6 +1518,8 @@ public AnnotatedTypeMirror getTypeOfExtendsImplements(Tree clause) {
AnnotatedTypeMirror fromTypeTree = fromTypeTree(clause);
AnnotationMirrorSet bound = getTypeDeclarationBounds(fromTypeTree.getUnderlyingType());
fromTypeTree.addMissingAnnotations(bound);
// Annotate any type variables in the type.
addComputedTypeAnnotations(clause, fromTypeTree);
return fromTypeTree;
}

Expand Down

0 comments on commit 19419ac

Please # to comment.