@@ -426,29 +426,28 @@ class DependencyRecorder {
426426
427427 private val _siblingClassfiles = new mutable.HashMap [PlainFile , Path ]
428428
429- extension (pf : PlainFile )
430- /** Constructs a sibling class to the `jpath`.
431- * Does not validate if it exists as a real file.
432- * The way this works is that by the end of compilation analysis,
433- * there should be a corresponding NonLocalClass sent to zinc with the same class file name.
434- *
435- * FIXME: we still need a way to resolve the correct classfile when we split tasty and classes between
436- * different outputs (e.g. stdlib-bootstrapped).
437- */
438- private def siblingClass : Path =
439- _siblingClassfiles.getOrElseUpdate(pf, {
440- val jpath = pf.jpath
441- jpath.getParent.resolve(jpath.getFileName.toString.stripSuffix(" .tasty" ) + " .class" )
442- })
429+ /** Constructs a sibling class to the `jpath`.
430+ * Does not validate if it exists as a real file.
431+ * The way this works is that by the end of compilation analysis,
432+ * there should be a corresponding NonLocalClass sent to zinc with the same class file name.
433+ *
434+ * FIXME: we still need a way to resolve the correct classfile when we split tasty and classes between
435+ * different outputs (e.g. stdlib-bootstrapped).
436+ */
437+ private def siblingClass (pf : PlainFile ): Path =
438+ _siblingClassfiles.getOrElseUpdate(pf, {
439+ val jpath = pf.jpath
440+ jpath.getParent.resolve(jpath.getFileName.toString.stripSuffix(" .tasty" ) + " .class" )
441+ })
443442
444443 /** Clear all state. */
445- def clear (): Unit =
446- _usedNames.clear()
447- _classDependencies.clear()
448- _siblingClassfiles.clear()
449- lastOwner = NoSymbol
450- lastDepSource = NoSymbol
451- _responsibleForImports = NoSymbol
444+ def clear (): Unit =
445+ _usedNames.clear()
446+ _classDependencies.clear()
447+ _siblingClassfiles.clear()
448+ lastOwner = NoSymbol
449+ lastDepSource = NoSymbol
450+ _responsibleForImports = NoSymbol
452451
453452 /** Handles dependency on given symbol by trying to figure out if represents a term
454453 * that is coming from either source code (not necessarily compiled in this compilation
@@ -461,32 +460,34 @@ class DependencyRecorder {
461460 def binaryDependency (path : Path , binaryClassName : String ) =
462461 cb.binaryDependency(path, binaryClassName, fromClassName, sourceFile, dep.context)
463462
464- def processExternalDependency (depFile : AbstractFile , binaryClassName : String , convertTasty : Boolean ) = {
465- depFile match {
466- case ze : ZipArchive # Entry => // The dependency comes from a JAR
467- ze.underlyingSource match
468- case Some (zip) if zip.jpath != null =>
469- binaryDependency(zip.jpath, binaryClassName)
470- case _ =>
471- case pf : PlainFile => // The dependency comes from a class file, Zinc handles JRT filesystem
472- binaryDependency(if convertTasty then pf.siblingClass else pf.jpath, binaryClassName)
473- case _ =>
474- internalError(s " Ignoring dependency $depFile of unknown class ${depFile.getClass}} " , dep.fromClass.srcPos)
475- }
476- }
477-
478- val depFile = dep.toClass.associatedFile
463+ val depClass = dep.toClass
464+ val depFile = depClass.associatedFile
479465 if depFile != null then {
480466 // Cannot ignore inheritance relationship coming from the same source (see sbt/zinc#417)
481467 def allowLocal = dep.context == DependencyByInheritance || dep.context == LocalDependencyByInheritance
482- if depFile.hasTastyExtension then
483- processExternalDependency(depFile, dep.toClass.binaryClassName, convertTasty = true )
484- else if depFile.hasClassExtension then
485- processExternalDependency(depFile, dep.toClass.binaryClassName, convertTasty = false )
468+ val isTasty = depFile.hasTastyExtension
469+
470+ def processExternalDependency () = {
471+ val binaryClassName = depClass.binaryClassName
472+ depFile match {
473+ case ze : ZipArchive # Entry => // The dependency comes from a JAR
474+ ze.underlyingSource match
475+ case Some (zip) if zip.jpath != null =>
476+ binaryDependency(zip.jpath, binaryClassName)
477+ case _ =>
478+ case pf : PlainFile => // The dependency comes from a class file, Zinc handles JRT filesystem
479+ binaryDependency(if isTasty then siblingClass(pf) else pf.jpath, binaryClassName)
480+ case _ =>
481+ internalError(s " Ignoring dependency $depFile of unknown class ${depFile.getClass}} " , dep.fromClass.srcPos)
482+ }
483+ }
484+
485+ if isTasty || depFile.hasClassExtension then
486+ processExternalDependency()
486487 else if allowLocal || depFile != sourceFile.file then
487488 // We cannot ignore dependencies coming from the same source file because
488489 // the dependency info needs to propagate. See source-dependencies/trait-trait-211.
489- val toClassName = classNameAsString(dep.toClass )
490+ val toClassName = classNameAsString(depClass )
490491 cb.classDependency(toClassName, fromClassName, dep.context)
491492 }
492493 }
0 commit comments