diff --git a/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinder.scala b/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinder.scala index 99cdc7d9a..5d67cd05f 100644 --- a/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinder.scala +++ b/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinder.scala @@ -45,13 +45,23 @@ class AstUsedJarFinder( case _ => } - if (tree.hasSymbolField) { - tree.symbol.annotations.foreach { annot => - annot.tree.foreach(fullyExploreTree) + val shouldExamine = + tree match { + case select: Select if select.symbol.isDefaultGetter => + false + case _ => + true + } + + if (shouldExamine) { + if (tree.hasSymbolField) { + tree.symbol.annotations.foreach { annot => + annot.tree.foreach(fullyExploreTree) + } + } + if (tree.tpe != null) { + exploreType(tree.tpe) } - } - if (tree.tpe != null) { - exploreType(tree.tpe) } } diff --git a/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinderTest.scala b/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinderTest.scala index 8066720f1..bd54fddf1 100644 --- a/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinderTest.scala +++ b/third_party/dependency_analyzer/src/test/io/bazel/rulesscala/dependencyanalyzer/AstUsedJarFinderTest.scala @@ -302,6 +302,19 @@ class AstUsedJarFinderTest extends FunSuite { ) } + test("unspecified default argument type is indirect") { + checkIndirectDependencyDetected( + aCode = "class A", + bCode = "class B(a: A = new A())", + cCode = + s""" + |class C { + | new B() + |} + |""".stripMargin + ) + } + test("java interface method argument is direct") { withSandbox { sandbox => sandbox.compileJava(