Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle default args in AST walker #986

Merged
merged 1 commit into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down