aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/transform/PostTyper.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Checking.scala5
-rw-r--r--tests/pos/i1723.scala8
4 files changed, 14 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
index 51f08a295..dad433c4e 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
@@ -733,11 +733,7 @@ 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)
- }
+ Checking.avoidPrivateLeaks(sym, tree.pos)
tree
}
diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala
index e7c0df1b9..8dff58dea 100644
--- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala
+++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala
@@ -107,12 +107,6 @@ 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)
- sym.copySymDenotation(info = info1).installAfter(thisTransformer)
- }
}
private def transformSelect(tree: Select, targs: List[Tree])(implicit ctx: Context): Tree = {
diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala
index 321c275d7..13c3b7617 100644
--- a/compiler/src/dotty/tools/dotc/typer/Checking.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala
@@ -343,6 +343,7 @@ object Checking {
fail(i"$sym cannot have the same name as ${cls.showLocated} -- class definitions cannot be overridden")
sym.setFlag(Private) // break the overriding relationship by making sym Private
}
+ avoidPrivateLeaks(sym, sym.pos)
}
/** Check the type signature of the symbol `M` defined by `tree` does not refer
@@ -412,6 +413,10 @@ object Checking {
info
}
+ def avoidPrivateLeaks(sym: Symbol, pos: Position)(implicit ctx: Context) =
+ if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass)
+ sym.info = checkNoPrivateLeaks(sym, pos)
+
/** Verify classes extending AnyVal meet the requirements */
def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(implicit ctx: Context) = {
def checkValueClassMember(stat: Tree) = stat match {
diff --git a/tests/pos/i1723.scala b/tests/pos/i1723.scala
new file mode 100644
index 000000000..75f7cd95c
--- /dev/null
+++ b/tests/pos/i1723.scala
@@ -0,0 +1,8 @@
+class A {
+ private val x: List[Int] = List(1)
+ def foo = x.head // foo inferred type is this.x.scala$collection$immutable$List$$A
+}
+
+class B extends A {
+ foo
+}