Skip to content

Commit 1e8860a

Browse files
committed
ClassfileParser: set privateWithin at symbol creation time for members
Third step towards making `privateWithin` force less.
1 parent 9fc9f21 commit 1e8860a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,12 @@ class ClassfileParser(
156156

157157
classRoot.setFlag(sflags)
158158
moduleRoot.setFlag(Flags.JavaDefined | Flags.ModuleClassCreationFlags)
159-
setPrivateWithin(classRoot, jflags)
160-
setPrivateWithin(moduleRoot, jflags)
161-
setPrivateWithin(moduleRoot.sourceModule, jflags)
159+
160+
val privateWithin = getPrivateWithin(jflags)
161+
162+
classRoot.privateWithin = privateWithin
163+
moduleRoot.privateWithin = privateWithin
164+
moduleRoot.sourceModule.privateWithin = privateWithin
162165

163166
for (i <- 0 until in.nextChar) parseMember(method = false)
164167
for (i <- 0 until in.nextChar) parseMember(method = true)
@@ -212,7 +215,8 @@ class ClassfileParser(
212215
val name = pool.getName(in.nextChar)
213216
if (!sflags.is(Flags.Private) || name == nme.CONSTRUCTOR) {
214217
val member = ctx.newSymbol(
215-
getOwner(jflags), name, sflags, memberCompleter, coord = start)
218+
getOwner(jflags), name, sflags, memberCompleter,
219+
getPrivateWithin(jflags), coord = start)
216220
getScope(jflags).enter(member)
217221
}
218222
// skip rest of member for now
@@ -263,7 +267,6 @@ class ClassfileParser(
263267
denot.info = pool.getType(in.nextChar)
264268
if (isEnum) denot.info = ConstantType(Constant(sym))
265269
if (isConstructor) normalizeConstructorParams()
266-
setPrivateWithin(denot, jflags)
267270
denot.info = translateTempPoly(parseAttributes(sym, denot.info))
268271
if (isConstructor) normalizeConstructorInfo()
269272

@@ -983,10 +986,11 @@ class ClassfileParser(
983986
protected def getScope(flags: Int): MutableScope =
984987
if (isStatic(flags)) staticScope else instanceScope
985988

986-
private def setPrivateWithin(denot: SymDenotation, jflags: Int)(implicit ctx: Context): Unit = {
989+
private def getPrivateWithin(jflags: Int)(implicit ctx: Context): Symbol =
987990
if ((jflags & (JAVA_ACC_PRIVATE | JAVA_ACC_PUBLIC)) == 0)
988-
denot.privateWithin = denot.enclosingPackageClass
989-
}
991+
classRoot.enclosingPackageClass
992+
else
993+
NoSymbol
990994

991995
private def isPrivate(flags: Int) = (flags & JAVA_ACC_PRIVATE) != 0
992996
private def isStatic(flags: Int) = (flags & JAVA_ACC_STATIC) != 0

0 commit comments

Comments
 (0)