@@ -189,6 +189,27 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
189
189
* but when it does we must ensure the incremental compiler tries its best no to lose
190
190
* any dependency. Therefore, we do a last-time effort to get the origin of the symbol
191
191
* by inspecting the classpath manually.
192
+ *
193
+ * UPDATE: This can also happen without compiler bugs if the symbol is simply uninitialized.
194
+ * Example, `class Client { def foo = Server.foo }`. When compiling client, the type `Foo` returned
195
+ * by `Server.foo` does not need to be initialized as we do not select from it or check its
196
+ * conformance to another type.
197
+ *
198
+ * Initializing `targetSymbol` before calling `assosicatedFile` would work but is problematic
199
+ * see zinc/zinc#949
200
+ *
201
+ * Perhaps consider this?
202
+ * val file = targetSymbol.associatedFile match {
203
+ * case NoAbstractFile => sym.rawInfo match {
204
+ * case cfl: global.loaders.ClassfileLoader =>
205
+ * val f = cfl.associatedFile(sym) // Gets the file from the loader
206
+ * if (f.exists) f else NoAbstractFile
207
+ * case f => f
208
+ * }
209
+ * }
210
+ *
211
+ * Or the status quo might just be perfectly fine -- if compilation doesn't need to force `Foo`,
212
+ * then there isn't a real dependency.
192
213
*/
193
214
val fqn = fullName(targetSymbol, '.' , targetSymbol.moduleSuffix, false )
194
215
global.findAssociatedFile(fqn) match {
@@ -291,9 +312,12 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
291
312
assert(fromClass.isClass, Feedback .expectedClassSymbol(fromClass))
292
313
val depClass = enclOrModuleClass(dep)
293
314
val dependency = ClassDependency (fromClass, depClass)
315
+ // An anonymous class be the enclosing class of an existential type symbol inferred from refinements,
316
+ // prior to https://github.com/scala/scala/pull/10940. Allowing this here leads to a dependency on class name
317
+ // that does not exist. Guard against it here to avoid the issue with legacy compiler versions.
294
318
if (
295
319
! cache.contains(dependency) &&
296
- ! depClass.isRefinementClass
320
+ ! depClass.isAnonOrRefinementClass
297
321
) {
298
322
process(dependency)
299
323
cache.add(dependency)
0 commit comments