Skip to content

Commit

Permalink
Prefer isPublic in RefChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Oct 22, 2024
1 parent d0fdbfb commit ae1b583
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ object RefChecks {

// todo: align accessibility implication checking with isAccessible in Contexts
def isOverrideAccessOK =
val memberIsPublic = (member.flags & AccessFlags).isEmpty && !member.privateWithin.exists
def protectedOK = !other.is(Protected) || member.is(Protected) // if o is protected, so is m
def accessBoundaryOK =
val ob = other.accessBoundary(member.owner)
Expand All @@ -534,7 +533,7 @@ object RefChecks {
def companionBoundaryOK = ob.isClass && !ob.isLocalToBlock && mb.is(Module) && (ob.companionModule eq mb.companionModule)
ob.isContainedIn(mb) || companionBoundaryOK // m relaxes o's access boundary,
def otherIsJavaProtected = other.isAllOf(JavaProtected) // or o is Java defined and protected (see #3946)
memberIsPublic || protectedOK && (accessBoundaryOK || otherIsJavaProtected)
member.isPublic || protectedOK && (accessBoundaryOK || otherIsJavaProtected)
end isOverrideAccessOK

if !member.hasTargetName(other.targetName) then
Expand Down Expand Up @@ -1169,8 +1168,7 @@ object RefChecks {
target.nonPrivateMember(sym.name)
.filterWithPredicate:
member =>
val memberIsPublic = (member.symbol.flags & AccessFlags).isEmpty && !member.symbol.privateWithin.exists
memberIsPublic && {
member.symbol.isPublic && {
val memberIsImplicit = member.info.hasImplicitParams
val paramTps =
if memberIsImplicit then methTp.stripPoly.firstParamTypes
Expand Down

0 comments on commit ae1b583

Please sign in to comment.