Skip to content

Commit b01e6a3

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. As a side effect this now forces less, which makes some previously failing tests pass. I updated i3253.scala so that it fails again and moved i9052 to pos.
1 parent f8d6ac4 commit b01e6a3

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

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

Lines changed: 5 additions & 5 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,13 @@ 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)
1016+
if hasUniqueSym && prevDenots.containsSym(symbol) then NoDenotation
1017+
else if isType then filterDisjoint(ownDenots).asSeenFrom(pre)
10181018
else asSeenFrom(pre).filterDisjoint(ownDenots)
10191019

1020-
final def filterWithPredicate(p: SingleDenotation => Boolean): SingleDenotation =
1020+
def filterWithPredicate(p: SingleDenotation => Boolean): SingleDenotation =
10211021
if (p(this)) this else NoDenotation
1022-
final def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation =
1022+
def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation =
10231023
if (denots.exists && denots.matches(this)) NoDenotation else this
10241024
def filterWithFlags(required: FlagSet, excluded: FlagSet)(using Context): SingleDenotation =
10251025
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
@@ -2325,6 +2325,13 @@ object SymDenotations {
23252325
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
23262326
override def computeAsSeenFrom(pre: Type)(using Context): SingleDenotation = this
23272327
override def mapInfo(f: Type => Type)(using Context): SingleDenotation = this
2328+
2329+
override def matches(other: SingleDenotation)(using Context): Boolean = false
2330+
override def mapInherited(ownDenots: PreDenotation, prevDenots: PreDenotation, pre: Type)(using Context): SingleDenotation = this
2331+
override def filterWithPredicate(p: SingleDenotation => Boolean): SingleDenotation = this
2332+
override def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation = this
2333+
override def filterWithFlags(required: FlagSet, excluded: FlagSet)(using Context): SingleDenotation = this
2334+
23282335
NoSymbol.denot = this
23292336
validFor = Period.allInRun(NoRunId)
23302337
}

tests/neg/i3253.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Test.test
22

3-
object Test {
3+
class A:
44
def test = " " * 10 // error
5-
}
5+
object Test extends A
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)