From 7586a43df2d0b67565a57cbe6b8054e5dfcc8eb7 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 3 Feb 2021 17:03:38 +0100 Subject: [PATCH 1/2] Load .tasty files from in-memory file systems too --- .../tools/dotc/core/classfile/ClassfileParser.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 2a709193656b..7f64ae43e7b8 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -917,8 +917,13 @@ class ClassfileParser( } case _ => if (classfile.jpath == null) { - report.error("Could not load TASTY from .tasty for virtual file " + classfile) - Array.empty + val tastyFileOrNull = classfile.container + .lookupName(classfile.name.stripSuffix(".class") + ".tasty", false) + if (tastyFileOrNull == null) { + report.error("Could not load TASTY from .tasty for virtual file " + classfile) + Array.empty + } else + tastyFileOrNull.toByteArray } else { val plainFile = new PlainFile(io.File(classfile.jpath).changeExtension("tasty")) if (plainFile.exists) plainFile.toByteArray From 7546edba0b93e201a6a7f7f04c1b540ac9c78533 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 3 Feb 2021 20:50:50 +0100 Subject: [PATCH 2/2] fixup (same code path for both virtual and plain files) --- .../dotc/core/classfile/ClassfileParser.scala | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 7f64ae43e7b8..aeaf6f11543b 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -916,22 +916,14 @@ class ClassfileParser( Array.empty } case _ => - if (classfile.jpath == null) { - val tastyFileOrNull = classfile.container - .lookupName(classfile.name.stripSuffix(".class") + ".tasty", false) - if (tastyFileOrNull == null) { - report.error("Could not load TASTY from .tasty for virtual file " + classfile) - Array.empty - } else - tastyFileOrNull.toByteArray - } 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 - } - } + 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 + tastyFileOrNull.toByteArray } if (tastyBytes.nonEmpty) { val reader = new TastyReader(bytes, 0, 16)