Skip to content

Commit 62582e9

Browse files
committed
Check exports for private leaks
1 parent 01f6669 commit 62582e9

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ class TreeUnpickler(reader: TastyReader,
846846
goto(end)
847847
setSpan(start, tree)
848848
if (!sym.isType) { // Only terms might have leaky aliases, see the documentation of `checkNoPrivateLeaks`
849-
sym.info = ta.avoidPrivateLeaks(sym, tree.sourcePos)
849+
sym.info = ta.avoidPrivateLeaks(sym)
850850
}
851851

852852
if (ctx.mode.is(Mode.ReadComments)) {

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ object Checking {
470470
*
471471
* @return The `info` of `sym`, with problematic aliases expanded away.
472472
*/
473-
def checkNoPrivateLeaks(sym: Symbol, pos: SourcePosition)(implicit ctx: Context): Type = {
473+
def checkNoPrivateLeaks(sym: Symbol)(implicit ctx: Context): Type = {
474474
class NotPrivate extends TypeMap {
475475
var errors: List[() => String] = Nil
476476

@@ -531,7 +531,7 @@ object Checking {
531531
}
532532
val notPrivate = new NotPrivate
533533
val info = notPrivate(sym.info)
534-
notPrivate.errors.foreach(error => ctx.errorOrMigrationWarning(error(), pos))
534+
notPrivate.errors.foreach(error => ctx.errorOrMigrationWarning(error(), sym.sourcePos))
535535
info
536536
}
537537

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ class Namer { typer: Typer =>
873873
denot.info = typeSig(sym)
874874
invalidateIfClashingSynthetic(denot)
875875
Checking.checkWellFormed(sym)
876-
denot.info = avoidPrivateLeaks(sym, sym.sourcePos)
876+
denot.info = avoidPrivateLeaks(sym)
877877
}
878878
}
879879

@@ -982,6 +982,7 @@ class Namer { typer: Typer =>
982982
val mbrFlags = Exported | Method | Final | maybeStable | mbr.symbol.flags & RetainedExportFlags
983983
ctx.newSymbol(cls, alias, mbrFlags, mbrInfo, coord = span)
984984
}
985+
forwarder.info = avoidPrivateLeaks(forwarder)
985986
val forwarderDef =
986987
if (forwarder.isType) tpd.TypeDef(forwarder.asType)
987988
else {
@@ -1146,7 +1147,7 @@ class Namer { typer: Typer =>
11461147

11471148
Checking.checkWellFormed(cls)
11481149
if (isDerivedValueClass(cls)) cls.setFlag(Final)
1149-
cls.info = avoidPrivateLeaks(cls, cls.sourcePos)
1150+
cls.info = avoidPrivateLeaks(cls)
11501151
cls.baseClasses.foreach(_.invalidateBaseTypeCache()) // we might have looked before and found nothing
11511152
cls.setNoInitsFlags(parentsKind(parents), bodyKind(rest))
11521153
if (cls.isNoInitsClass) cls.primaryConstructor.setFlag(StableRealizable)

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ trait TypeAssigner {
155155
def avoidingType(expr: Tree, bindings: List[Tree])(implicit ctx: Context): Type =
156156
avoid(expr.tpe, localSyms(bindings).filter(_.isTerm))
157157

158-
def avoidPrivateLeaks(sym: Symbol, pos: SourcePosition)(implicit ctx: Context): Type =
159-
if (!sym.isOneOf(PrivateOrSynthetic) && sym.owner.isClass) checkNoPrivateLeaks(sym, pos)
158+
def avoidPrivateLeaks(sym: Symbol)(implicit ctx: Context): Type =
159+
if (!sym.isOneOf(PrivateOrSynthetic) && sym.owner.isClass) checkNoPrivateLeaks(sym)
160160
else sym.info
161161

162162
private def toRepeated(tree: Tree, from: ClassSymbol)(implicit ctx: Context): Tree =

0 commit comments

Comments
 (0)