Skip to content

Commit

Permalink
require explicit enabling of reading outline TASTy with -from-tasty
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Nov 27, 2023
1 parent a715de6 commit 209c83b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 209c83b

Please sign in to comment.