@@ -4,6 +4,7 @@ package sbt
44import scala .language .unsafeNulls
55
66import java .io .File
7+ import java .nio .file .Path
78import java .util .{Arrays , EnumSet }
89
910import dotty .tools .dotc .ast .tpd
@@ -54,8 +55,7 @@ class ExtractDependencies extends Phase {
5455 override def description : String = ExtractDependencies .description
5556
5657 override def isRunnable (using Context ): Boolean = {
57- def forceRun = ctx.settings.YdumpSbtInc .value || ctx.settings.YforceSbtPhases .value
58- super .isRunnable && (ctx.sbtCallback != null || forceRun)
58+ super .isRunnable && ctx.runZincPhases
5959 }
6060
6161 // Check no needed. Does not transform trees
@@ -90,18 +90,16 @@ class ExtractDependencies extends Phase {
9090 } finally pw.close()
9191 }
9292
93- if ( ctx.sbtCallback != null ) {
93+ ctx.withIncCallback : cb =>
9494 collector.usedNames.foreach {
9595 case (clazz, usedNames) =>
9696 val className = classNameAsString(clazz)
9797 usedNames.names.foreach {
9898 case (usedName, scopes) =>
99- ctx.sbtCallback .usedName(className, usedName.toString, scopes)
99+ cb .usedName(className, usedName.toString, scopes)
100100 }
101101 }
102-
103102 collector.dependencies.foreach(recordDependency)
104- }
105103 }
106104
107105 /*
@@ -111,27 +109,20 @@ class ExtractDependencies extends Phase {
111109 */
112110 def recordDependency (dep : ClassDependency )(using Context ): Unit = {
113111 val fromClassName = classNameAsString(dep.from)
114- val sourceFile = ctx.compilationUnit.source.file.file
112+ val sourceFile = ctx.compilationUnit.source
115113
116- def binaryDependency (file : File , binaryClassName : String ) =
117- ctx.sbtCallback .binaryDependency(file, binaryClassName, fromClassName, sourceFile, dep.context)
114+ def binaryDependency (file : Path , binaryClassName : String ) =
115+ ctx.withIncCallback(_ .binaryDependency(file, binaryClassName, fromClassName, sourceFile, dep.context) )
118116
119117 def processExternalDependency (depFile : AbstractFile , binaryClassName : String ) = {
120118 depFile match {
121119 case ze : ZipArchive # Entry => // The dependency comes from a JAR
122120 ze.underlyingSource match
123- case Some (zip) if zip.file != null =>
124- binaryDependency(zip.file , binaryClassName)
121+ case Some (zip) if zip.jpath != null =>
122+ binaryDependency(zip.jpath , binaryClassName)
125123 case _ =>
126- case pf : PlainFile => // The dependency comes from a class file
127- // FIXME: pf.file is null for classfiles coming from the modulepath
128- // (handled by JrtClassPath) because they cannot be represented as
129- // java.io.File, since the `binaryDependency` callback must take a
130- // java.io.File, this means that we cannot record dependencies coming
131- // from the modulepath. For now this isn't a big deal since we only
132- // support having the standard Java library on the modulepath.
133- if pf.file != null then
134- binaryDependency(pf.file, binaryClassName)
124+ case pf : PlainFile => // The dependency comes from a class file, Zinc handles JRT filesystem
125+ binaryDependency(pf.jpath, binaryClassName)
135126 case _ =>
136127 internalError(s " Ignoring dependency $depFile of unknown class ${depFile.getClass}} " , dep.from.srcPos)
137128 }
@@ -144,11 +135,11 @@ class ExtractDependencies extends Phase {
144135 if (depFile.extension == " class" ) {
145136 // Dependency is external -- source is undefined
146137 processExternalDependency(depFile, dep.to.binaryClassName)
147- } else if (allowLocal || depFile.file != sourceFile) {
138+ } else if (allowLocal || depFile != sourceFile.file ) {
148139 // We cannot ignore dependencies coming from the same source file because
149140 // the dependency info needs to propagate. See source-dependencies/trait-trait-211.
150141 val toClassName = classNameAsString(dep.to)
151- ctx.sbtCallback .classDependency(toClassName, fromClassName, dep.context)
142+ ctx.withIncCallback(_ .classDependency(toClassName, fromClassName, dep.context) )
152143 }
153144 }
154145 }
0 commit comments