Skip to content

Commit df8b202

Browse files
committed
require explicit enabling of reading outline TASTy with -from-tasty
1 parent 5102e08 commit df8b202

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,4 +437,5 @@ private sealed trait YSettings:
437437
// Pipeline compilation options
438438
val YjavaTasty: Setting[Boolean] = BooleanSetting("-Yjava-tasty", "Pickler phase should compute pickles for .java defined symbols for use by build tools")
439439
val YjavaTastyOutput: Setting[AbstractFile] = OutputSetting("-Yjava-tasty-output", "directory|jar", "(Internal use only!) destination for generated .tasty files containing Java type signatures.", NoAbstractFile)
440+
val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting("-Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.")
440441
end YSettings

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import dotty.tools.tasty.TastyFormat.*
4646
import scala.annotation.constructorOnly
4747
import scala.annotation.internal.sharable
4848
import scala.compiletime.uninitialized
49-
import dotty.tools.tasty.UnpickleException
5049

5150
/** Unpickler for typed trees
5251
* @param reader the reader from which to unpickle
@@ -120,9 +119,6 @@ class TreeUnpickler(reader: TastyReader,
120119
*/
121120
def enter(roots: Set[SymDenotation])(using Context): Unit = {
122121
this.roots = roots
123-
if isOutline && !unpicklingJava then
124-
// TODO: overly cautious here, eventually we could enable this with 2-pass compilation.
125-
throw UnpickleException("Outline TASTy is not supported for Scala sources.")
126122
val rdr = new TreeReader(reader).fork
127123
ownerTree = new OwnerTree(NoAddr, 0, rdr.fork, reader.endAddr)
128124
if (rdr.isTopLevel)

compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class ReadTasty extends Phase {
5050
if attributes.isJava && !ctx.settings.YjavaTasty.value then
5151
// filter out Java compilation units if -Yjava-tasty is not set
5252
None
53+
else if attributes.isOutline && !ctx.settings.YallowOutlineFromTasty.value then
54+
cannotUnpickle("it contains outline signatures and -Yallow-outline-from-tasty is not set.")
5355
else
5456
val unit = CompilationUnit(cls, cls.rootTree, forceTrees = true)
5557
unit.pickled += (cls -> (() => unpickler.unpickler.bytes))

sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ lazy val a_from_tasty = project.in(file("a_from_tasty"))
1616
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar")),
1717
scalacOptions += "-from-tasty", // read the jar file tasties as the source files
1818
scalacOptions += "-Yjava-tasty",
19+
scalacOptions += "-Yallow-outline-from-tasty", // allow outline signatures to be read with -from-tasty
1920
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar").toString),
2021
scalacOptions += "-Ycheck:all",
2122
classDirectory := ((ThisBuild / baseDirectory).value / "a_from_tasty-classes"), // send classfiles to a different directory

0 commit comments

Comments
 (0)