@@ -165,6 +165,30 @@ private class ExtractDependenciesCollector(rec: DependencyRecorder) extends tpd.
165165 rec.addClassDependency(parent.tpe.classSymbol, depContext)
166166 }
167167
168+ // Only reference DependencyByMacroExpansion if it an be found on the classpath,
169+ // as it was added later to the zinc.apiinfo DependencyContext enum
170+ // e.g. pre 1.10.x sbt would throw java.lang.NoSuchFieldError errors here
171+ lazy val allowsDependencyByMacroExpansion =
172+ classOf [DependencyContext ].getFields().exists(_.getName() == " DependencyByMacroExpansion" )
173+
174+ private def addMacroDependency (sym : Symbol )(using Context ): Unit =
175+ if (allowsDependencyByMacroExpansion) {
176+ if (! ignoreDependency(sym)) {
177+ if (! sym.is(Package )) {
178+ val enclOrModuleClass = if (sym.is(ModuleVal )) sym.moduleClass else sym.enclosingClass
179+ assert(enclOrModuleClass.isClass, s " $enclOrModuleClass, $sym" )
180+
181+ rec.addClassDependency(enclOrModuleClass, DependencyByMacroExpansion )
182+ }
183+ }
184+ }
185+
186+ private def addMacroDependency (trees : List [Tree ])(using Context ): Unit =
187+ val traverser = new TypeDependencyTraverser {
188+ def addDependency (symbol : Symbol ) = addMacroDependency(symbol)
189+ }
190+ trees.foreach(tree => traverser.traverse(tree.tpe))
191+
168192 private def depContextOf (cls : Symbol )(using Context ): DependencyContext =
169193 if cls.isLocal then LocalDependencyByInheritance
170194 else DependencyByInheritance
@@ -226,6 +250,11 @@ private class ExtractDependenciesCollector(rec: DependencyRecorder) extends tpd.
226250 case _ =>
227251 }
228252
253+ tree match
254+ case TypeApply (fun, args) if fun.symbol.is(Inline ) =>
255+ addMacroDependency(args)
256+ case _ =>
257+
229258 tree match {
230259 case tree : Inlined if ! tree.inlinedFromOuterScope =>
231260 // The inlined call is normally ignored by TreeTraverser but we need to
0 commit comments