From 35cbf65f4fca3360ad8a41a2bf3cfb54c0a9aa09 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 15 Jun 2017 18:26:19 +0200 Subject: [PATCH 1/2] InteractiveDriver: Always look for hasTasty files When we changed the tasty marker to be either .hasTasty or .tasty files, we missed a few places where we need to look for either of them. --- .../dotc/interactive/InteractiveDriver.scala | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index c19bc0556f8a..10e7528bb333 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -69,6 +69,10 @@ class InteractiveDriver(settings: List[String]) extends Driver { } } + // Presence of a file with one of these suffixes indicates that the + // corresponding class has been pickled with TASTY. + private val tastySuffixes = List(".hasTasty", ".tasty") + private def classNames(cp: ClassPath, packageName: String): List[String] = { def className(classSegments: List[String]) = classSegments.mkString(".").stripSuffix(".class") @@ -85,9 +89,6 @@ class InteractiveDriver(settings: List[String]) extends Driver { binFile.name.stripSuffix(".class") else null - // Presence of a file with one of these suffixes indicates that the - // corresponding class has been pickled with TASTY. - val tastySuffixes = List(".hasTasty", ".tasty") prefix != null && { binFile match { case pf: PlainFile => @@ -123,8 +124,12 @@ class InteractiveDriver(settings: List[String]) extends Driver { .stream .toArray(new IntFunction[Array[ZipEntry]] { def apply(size: Int) = new Array(size) }) .toSeq - entries.filter(_.getName.endsWith(".tasty")) - .map(_.getName.replace("/", ".").stripSuffix(".tasty")) + for { + entry <- entries + name = entry.getName + tastySuffix <- tastySuffixes + if name.endsWith(tastySuffix) + } yield name.replace("/", ".").stripSuffix(tastySuffix) } // FIXME: classfiles in directories may change at any point, so we retraverse @@ -136,8 +141,14 @@ class InteractiveDriver(settings: List[String]) extends Driver { val root = dirCp.dir.toPath Files.walkFileTree(root, new SimpleFileVisitor[Path] { override def visitFile(path: Path, attrs: BasicFileAttributes) = { - if (!attrs.isDirectory && path.getFileName.toString.endsWith(".tasty")) { - names += root.relativize(path).toString.replace("/", ".").stripSuffix(".tasty") + if (!attrs.isDirectory) { + val name = path.getFileName.toString + for { + tastySuffix <- tastySuffixes + if name.endsWith(tastySuffix) + } { + names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix) + } } FileVisitResult.CONTINUE } From cebef3b4731998dc7375b01a9ee77bc1a19d8eb7 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 15 Jun 2017 18:52:38 +0200 Subject: [PATCH 2/2] ClassSymbol#tree: don't forget to force the info Otherwise the tree might not exist yet --- compiler/src/dotty/tools/dotc/core/Symbols.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index d840af088b46..f32b1da7d33b 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -556,9 +556,10 @@ object Symbols { type ThisName = TypeName /** If this is a top-level class, and if `-Yretain-trees` is set, return the TypeDef tree - * for this class, otherwise EmptyTree. + * for this class, otherwise EmptyTree. This will force the info of the class. */ def tree(implicit ctx: Context): tpd.Tree /* tpd.TypeDef | tpd.EmptyTree */ = { + denot.info // TODO: Consider storing this tree like we store lazy trees for inline functions if (unpickler != null && !denot.isAbsent) { assert(myTree.isEmpty)