Skip to content

Commit 2e14093

Browse files
committed
Add SymDenotation#isPublic
Also replace the `isPublic` in `DottyBackendInterface` by this one, note that the new definition fixes a bug in the previous one: private-qualified symbols do not have the `Private` flag set (see `ParserCommon#normalize`) but are still not public.
1 parent bcb41a1 commit 2e14093

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile)(implicit ctx: Context
569569
def isConstructor: Boolean = toDenot(sym).isConstructor
570570
def isAnonymousFunction: Boolean = toDenot(sym).isAnonymousFunction
571571
def isMethod: Boolean = sym is Flags.Method
572-
def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, Flags.Private | Flags.Protected)
572+
def isPublic: Boolean = toDenot(sym).isPublic
573573
def isSynthetic: Boolean = sym is Flags.Synthetic
574574
def isPackageClass: Boolean = sym is Flags.PackageClass
575575
def isModuleClass: Boolean = sym is Flags.ModuleClass

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,12 @@ object SymDenotations {
10601060
else defn.RootClass
10611061
}
10621062

1063+
/** Is this denotation public ? */
1064+
def isPublic(implicit ctx: Context): Boolean =
1065+
// private-qualified denotations do not have the Private flag set,
1066+
// see `ParserCommon#normalize`
1067+
!this.is(Protected | Private) && !privateWithin.exists
1068+
10631069
/** The primary constructor of a class or trait, NoSymbol if not applicable. */
10641070
def primaryConstructor(implicit ctx: Context): Symbol = NoSymbol
10651071

0 commit comments

Comments
 (0)