Skip to content

Commit ccde318

Browse files
committed
accessBoundary: Avoid forcing completion when possible
Calling `this.flags` requires completing the denotation, but directly caling `is(...)` doesn't if the flags are FromStartFlags/AfterLoadFlags. Most calls to `accessBoundary` will still require forcing because of the call to `privateWithin`, this is fixed by the next few commits by making `privateWithin` require less forcing.
1 parent a92a209 commit ccde318

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,14 +1269,12 @@ object SymDenotations {
12691269
* as public.
12701270
* @param base The access boundary to assume if this symbol is protected
12711271
*/
1272-
final def accessBoundary(base: Symbol)(implicit ctx: Context): Symbol = {
1273-
val fs = flags
1274-
if (fs.is(Private)) owner
1275-
else if (fs.isAllOf(StaticProtected)) defn.RootClass
1272+
final def accessBoundary(base: Symbol)(implicit ctx: Context): Symbol =
1273+
if (this.is(Private)) owner
1274+
else if (this.isAllOf(StaticProtected)) defn.RootClass
12761275
else if (privateWithin.exists && !ctx.phase.erasedTypes) privateWithin
1277-
else if (fs.is(Protected)) base
1276+
else if (this.is(Protected)) base
12781277
else defn.RootClass
1279-
}
12801278

12811279
final def isPublic(implicit ctx: Context): Boolean =
12821280
accessBoundary(owner) == defn.RootClass

0 commit comments

Comments
 (0)