diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 2a709193656b..aeaf6f11543b 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -916,17 +916,14 @@ class ClassfileParser( Array.empty } case _ => - if (classfile.jpath == null) { - report.error("Could not load TASTY from .tasty for virtual file " + classfile) + val dir = classfile.container + val name = classfile.name.stripSuffix(".class") + ".tasty" + val tastyFileOrNull = dir.lookupName(name, false) + if (tastyFileOrNull == null) { + report.error(s"Could not find TASTY file $name under $dir") Array.empty - } else { - val plainFile = new PlainFile(io.File(classfile.jpath).changeExtension("tasty")) - if (plainFile.exists) plainFile.toByteArray - else { - report.error("Could not find " + plainFile) - Array.empty - } - } + } else + tastyFileOrNull.toByteArray } if (tastyBytes.nonEmpty) { val reader = new TastyReader(bytes, 0, 16)