diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index ea6c9bd0a527..a71f28f49410 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -437,4 +437,5 @@ private sealed trait YSettings: // Pipeline compilation options val YjavaTasty: Setting[Boolean] = BooleanSetting("-Yjava-tasty", "Pickler phase should compute pickles for .java defined symbols for use by build tools") val YjavaTastyOutput: Setting[AbstractFile] = OutputSetting("-Yjava-tasty-output", "directory|jar", "(Internal use only!) destination for generated .tasty files containing Java type signatures.", NoAbstractFile) + val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting("-Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.") end YSettings diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index b93954c37b46..7c7b51e1def6 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -46,7 +46,6 @@ import dotty.tools.tasty.TastyFormat.* import scala.annotation.constructorOnly import scala.annotation.internal.sharable import scala.compiletime.uninitialized -import dotty.tools.tasty.UnpickleException /** Unpickler for typed trees * @param reader the reader from which to unpickle @@ -120,9 +119,6 @@ class TreeUnpickler(reader: TastyReader, */ def enter(roots: Set[SymDenotation])(using Context): Unit = { this.roots = roots - if isOutline && !unpicklingJava then - // TODO: overly cautious here, eventually we could enable this with 2-pass compilation. - throw UnpickleException("Outline TASTy is not supported for Scala sources.") val rdr = new TreeReader(reader).fork ownerTree = new OwnerTree(NoAddr, 0, rdr.fork, reader.endAddr) if (rdr.isTopLevel) diff --git a/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala b/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala index fe6386d8c263..e24e76070505 100644 --- a/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala +++ b/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala @@ -50,6 +50,8 @@ class ReadTasty extends Phase { if attributes.isJava && !ctx.settings.YjavaTasty.value then // filter out Java compilation units if -Yjava-tasty is not set None + else if attributes.isOutline && !ctx.settings.YallowOutlineFromTasty.value then + cannotUnpickle("it contains outline signatures and -Yallow-outline-from-tasty is not set.") else val unit = CompilationUnit(cls, cls.rootTree, forceTrees = true) unit.pickled += (cls -> (() => unpickler.unpickler.bytes)) diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt b/sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt index 1e129b3ea52e..dc4950ec8379 100644 --- a/sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt +++ b/sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt @@ -16,6 +16,7 @@ lazy val a_from_tasty = project.in(file("a_from_tasty")) Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar")), scalacOptions += "-from-tasty", // read the jar file tasties as the source files scalacOptions += "-Yjava-tasty", + scalacOptions += "-Yallow-outline-from-tasty", // allow outline signatures to be read with -from-tasty scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", classDirectory := ((ThisBuild / baseDirectory).value / "a_from_tasty-classes"), // send classfiles to a different directory