Skip to content

Commit

Permalink
Add checks against NoType
Browse files Browse the repository at this point in the history
They are not relevant and their effect on performance is minimal, but
it's good to have them for consistency. We do check for `NoSymbol` as
well as `null` when it comes to symbols. It feels weird if we don't for
types.
  • Loading branch information
jvican committed Feb 2, 2017
1 parent a2c4ad5 commit fad19ce
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/compiler-bridge/src/main/scala/xsbt/Dependency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,17 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
}
}

@inline
def ignoreType(tpe: Type) =
tpe == null ||
tpe == NoType ||
tpe.typeSymbol == EmptyPackageClass

private def addTreeDependency(tree: Tree): Unit = {
addDependency(tree.symbol)
if (tree.tpe != null)
foreachSymbolInType(tree.tpe)(addDependency)
val tpe = tree.tpe
if (!ignoreType(tpe))
foreachSymbolInType(tpe)(addDependency)
()
}
private def addDependency(dep: Symbol): Unit = {
Expand Down Expand Up @@ -269,7 +276,7 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
traverseTrees(body)

// In some cases (eg. macro annotations), `typeTree.tpe` may be null. See sbt/sbt#1593 and sbt/sbt#1655.
case typeTree: TypeTree if typeTree.tpe != null =>
case typeTree: TypeTree if !ignoreType(typeTree.tpe) =>
symbolsInType(typeTree.tpe) foreach addDependency
case m @ MacroExpansionOf(original) if inspectedOriginalTrees.add(original) =>
traverse(original)
Expand Down

0 comments on commit fad19ce

Please sign in to comment.