Skip to content

Commit

Permalink
Ignore base class annotation (bazelbuild#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie5 authored and Andre Rocha committed Jul 6, 2020
1 parent fae42a4 commit acb05f9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,20 @@ class AstUsedJarFinder(

if (shouldExamine) {
if (tree.hasSymbolField) {
tree.symbol.annotations.foreach(exploreAnnotationInfo)
tree.symbol.annotations
// We skip annotations without positions. The reason for
// this is the case of
// @SomeAnnotation class A
// class B extends A
// Now assuming A and B are in separate packages, while
// examining B we will examine A as well, and hence
// examine A's annotations. However we don't wish to examine
// A's annotations as we don't care about those details of A.
// Hence we only examine annotations with positions (hence,
// they were defined in the same compilation unit and thus
// matter).
.filter(_.pos.isDefined)
.foreach(exploreAnnotationInfo)
}
if (tree.tpe != null) {
exploreType(tree.tpe, tree.pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ class AstUsedJarFinderTest extends FunSuite {
)
}

test("static annotation of inherited class is indirect") {
checkIndirectDependencyDetected(
aCode = "class A extends scala.annotation.StaticAnnotation",
bCode = "@A class B",
cCode = "class C extends B"
)
}

test("class type parameter bound is direct") {
checkDirectDependencyRecognized(
aCode =
Expand Down

0 comments on commit acb05f9

Please sign in to comment.