@@ -75,7 +75,7 @@ class ExtractDependencies extends Phase {
75
75
if (ctx.sbtCallback != null ) {
76
76
extractDeps.usedNames.foreach {
77
77
case (clazz, usedNames) =>
78
- val className = clazz
78
+ val className = classNameAsString( clazz)
79
79
usedNames.names.foreach {
80
80
case (usedName, scopes) =>
81
81
ctx.sbtCallback.usedName(className, usedName.toString, scopes)
@@ -187,13 +187,13 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
187
187
import tpd ._
188
188
import ExtractDependencies ._
189
189
190
- private [this ] val _usedNames = new mutable.HashMap [String , UsedNamesInClass ]
190
+ private [this ] val _usedNames = new mutable.HashMap [Symbol , UsedNamesInClass ]
191
191
private [this ] val _dependencies = new mutable.HashSet [ClassDependency ]
192
192
193
193
/** The names used in this class, this does not include names which are only
194
194
* defined and not referenced.
195
195
*/
196
- def usedNames : collection.Map [String , UsedNamesInClass ] = _usedNames
196
+ def usedNames : collection.Map [Symbol , UsedNamesInClass ] = _usedNames
197
197
198
198
/** The set of class dependencies from this compilation unit.
199
199
*/
@@ -242,12 +242,17 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
242
242
if (source.isEffectiveRoot) responsibleForImports else source
243
243
}
244
244
245
- private def addUsedName (enclosingSym : Symbol , name : Name , scope : UseScope )(implicit ctx : Context ) = {
246
- val enclosingName =
247
- if (enclosingSym == defn.RootClass ) classNameAsString(responsibleForImports)
248
- else classNameAsString(enclosingSym)
249
- val nameUsed = _usedNames.getOrElseUpdate(enclosingName, new UsedNamesInClass )
250
- nameUsed.update(name, scope)
245
+ private def addUsedName (fromClass : Symbol , name : Name , scope : UseScope ): Unit = {
246
+ val usedName = _usedNames.getOrElseUpdate(fromClass, new UsedNamesInClass )
247
+ usedName.update(name, scope)
248
+ }
249
+
250
+ private def addUsedName (name : Name , scope : UseScope )(implicit ctx : Context ): Unit = {
251
+ val fromClass = resolveDependencySource
252
+ if (fromClass ne NoSymbol ) {
253
+ assert(fromClass.isClass)
254
+ addUsedName(fromClass, name, scope)
255
+ }
251
256
}
252
257
253
258
private def addDependency (sym : Symbol )(implicit ctx : Context ): Unit =
@@ -298,7 +303,7 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
298
303
case Thicket (Ident (name) :: Ident (rename) :: Nil ) =>
299
304
addImported(name)
300
305
if (rename ne nme.WILDCARD ) {
301
- addUsedName(resolveDependencySource, rename, UseScope .Default )
306
+ addUsedName(rename, UseScope .Default )
302
307
}
303
308
case _ =>
304
309
}
@@ -389,10 +394,9 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
389
394
val traverser = new TypeDependencyTraverser {
390
395
def addDependency (symbol : Symbol ) =
391
396
if (! ignoreDependency(symbol) && symbol.is(Sealed )) {
392
- val enclosingSym = resolveDependencySource
393
397
val usedName = symbol.name.stripModuleClassSuffix
394
- addUsedName(enclosingSym, usedName, UseScope .Default )
395
- addUsedName(enclosingSym, usedName, UseScope .PatMatTarget )
398
+ addUsedName(usedName, UseScope .Default )
399
+ addUsedName(usedName, UseScope .PatMatTarget )
396
400
}
397
401
}
398
402
traverser.traverse(tpe)
0 commit comments