Skip to content

Commit 907f7a0

Browse files
committed
Special case PreDenotation ops for NoDenotation
NoDenotation is a frequent result, so we should keep post processing it as simple as possible.
1 parent cf6531d commit 907f7a0

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ object Denotations {
982982
final def first: SingleDenotation = this
983983
final def last: SingleDenotation = this
984984

985-
final def matches(other: SingleDenotation)(using Context): Boolean =
985+
def matches(other: SingleDenotation)(using Context): Boolean =
986986
val d = signature.matchDegree(other.signature)
987987

988988
d match
@@ -1013,13 +1013,16 @@ object Denotations {
10131013
end matches
10141014

10151015
def mapInherited(ownDenots: PreDenotation, prevDenots: PreDenotation, pre: Type)(using Context): SingleDenotation =
1016-
if (hasUniqueSym && prevDenots.containsSym(symbol)) NoDenotation
1017-
else if (isType) filterDisjoint(ownDenots).asSeenFrom(pre)
1018-
else asSeenFrom(pre).filterDisjoint(ownDenots)
1016+
if hasUniqueSym && (symbol.is(Private) || prevDenots.containsSym(symbol)) then
1017+
NoDenotation
1018+
else if isType then
1019+
filterDisjoint(ownDenots).asSeenFrom(pre)
1020+
else
1021+
asSeenFrom(pre).filterDisjoint(ownDenots)
10191022

1020-
final def filterWithPredicate(p: SingleDenotation => Boolean): SingleDenotation =
1023+
def filterWithPredicate(p: SingleDenotation => Boolean): SingleDenotation =
10211024
if (p(this)) this else NoDenotation
1022-
final def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation =
1025+
def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation =
10231026
if (denots.exists && denots.matches(this)) NoDenotation else this
10241027
def filterWithFlags(required: FlagSet, excluded: FlagSet)(using Context): SingleDenotation =
10251028
if (required.isEmpty && excluded.isEmpty || compatibleWith(required, excluded)) this else NoDenotation

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,13 @@ object SymDenotations {
23132313
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
23142314
override def computeAsSeenFrom(pre: Type)(using Context): SingleDenotation = this
23152315
override def mapInfo(f: Type => Type)(using Context): SingleDenotation = this
2316+
2317+
override def matches(other: SingleDenotation)(using Context): Boolean = false
2318+
override def mapInherited(ownDenots: PreDenotation, prevDenots: PreDenotation, pre: Type)(using Context): SingleDenotation = this
2319+
override def filterWithPredicate(p: SingleDenotation => Boolean): SingleDenotation = this
2320+
override def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation = this
2321+
override def filterWithFlags(required: FlagSet, excluded: FlagSet)(using Context): SingleDenotation = this
2322+
23162323
NoSymbol.denot = this
23172324
validFor = Period.allInRun(NoRunId)
23182325
}

0 commit comments

Comments
 (0)