Skip to content

Commit 9f6d8b2

Browse files
committed
checkNoPrivateLeaks is now also done in TreeUnpickler
This could be abstracted better but we'll end up replacing checkNoPrivateLeaks soon anyway due to #1723
1 parent 21935f9 commit 9f6d8b2

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import scala.annotation.{tailrec, switch}
1414
import scala.collection.mutable.ListBuffer
1515
import scala.collection.{ mutable, immutable }
1616
import config.Printers.pickling
17+
import typer.Checking
1718

1819
/** Unpickler for typed trees
1920
* @param reader the reader from which to unpickle
@@ -723,6 +724,12 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle
723724
// no longer necessary.
724725
goto(end)
725726
setPos(start, tree)
727+
728+
// This is also done in PostTyper but needs to be redone here
729+
if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass) {
730+
sym.info = Checking.checkNoPrivateLeaks(sym, tree.pos)
731+
}
732+
tree
726733
}
727734

728735
private def readTemplate(implicit ctx: Context): Template = {

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
107107
private def transformMemberDef(tree: MemberDef)(implicit ctx: Context): Unit = {
108108
val sym = tree.symbol
109109
sym.transformAnnotations(transformAnnot)
110+
// Has to be redone in TreeUnpickler
110111
if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass) {
111112
val info1 = Checking.checkNoPrivateLeaks(sym, tree.pos)
112113
if (info1 ne sym.info)

tests/pickling/private-leak.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package private_leak
2+
3+
class Test {
4+
private type Foo = Int
5+
6+
val x: Foo = 1
7+
8+
x // unpickled with type Foo
9+
}

0 commit comments

Comments
 (0)