Skip to content

Commit

Permalink
Cleaner logic to handle types of extends and implements clause and fi…
Browse files Browse the repository at this point in the history
…xed `getTypeOfExtendsImplements` (eisop#199)
  • Loading branch information
piyush-J authored Jan 23, 2022
1 parent 345e7bb commit e790643
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,25 +544,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 @@ -1414,6 +1414,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 e790643

Please sign in to comment.