aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala7
-rw-r--r--compiler/src/dotty/tools/dotc/transform/PostTyper.scala1
-rw-r--r--tests/pickling/private-leak.scala9
3 files changed, 17 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
index 79408ddde..1d23a902a 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
@@ -14,6 +14,7 @@ import scala.annotation.{tailrec, switch}
import scala.collection.mutable.ListBuffer
import scala.collection.{ mutable, immutable }
import config.Printers.pickling
+import typer.Checking
/** Unpickler for typed trees
* @param reader the reader from which to unpickle
@@ -732,6 +733,12 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
// no longer necessary.
goto(end)
setPos(start, tree)
+
+ // This is also done in PostTyper but needs to be redone here
+ if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass) {
+ sym.info = Checking.checkNoPrivateLeaks(sym, tree.pos)
+ }
+ tree
}
private def readTemplate(implicit ctx: Context): Template = {
diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala
index 1ed47d92e..e7c0df1b9 100644
--- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala
+++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala
@@ -107,6 +107,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
private def transformMemberDef(tree: MemberDef)(implicit ctx: Context): Unit = {
val sym = tree.symbol
sym.transformAnnotations(transformAnnot)
+ // Has to be redone in TreeUnpickler
if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass) {
val info1 = Checking.checkNoPrivateLeaks(sym, tree.pos)
if (info1 ne sym.info)
diff --git a/tests/pickling/private-leak.scala b/tests/pickling/private-leak.scala
new file mode 100644
index 000000000..3fc32b519
--- /dev/null
+++ b/tests/pickling/private-leak.scala
@@ -0,0 +1,9 @@
+package private_leak
+
+class Test {
+ private type Foo = Int
+
+ val x: Foo = 1
+
+ x // unpickled with type Foo
+}