Skip to content

Commit a29edc4

Browse files
committed
Don't use export on MatchDegree
Even the mitigation would have needed a workaround (because of scala#6741).
1 parent 422d2a9 commit a29edc4

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,10 @@ object Denotations {
756756
if (!symbol.exists || symbol.isAccessibleFrom(pre, superAccess)) this else NoDenotation
757757

758758
def atSignature(sig: Signature, site: Type, relaxed: Boolean)(implicit ctx: Context): SingleDenotation = {
759+
import Signature.MatchDegree._
759760
val situated = if (site == NoPrefix) this else asSeenFrom(site)
760761
val matches = sig.matchDegree(situated.signature).ordinal >=
761-
(if (relaxed) Signature.ParamMatch else Signature.FullMatch).ordinal
762+
(if (relaxed) ParamMatch else FullMatch).ordinal
762763
if (matches) this else NoDenotation
763764
}
764765

@@ -1090,13 +1091,14 @@ object Denotations {
10901091
final def last: SingleDenotation = this
10911092

10921093
final def matches(other: SingleDenotation)(implicit ctx: Context): Boolean = {
1094+
import Signature.MatchDegree._
10931095
val d = signature.matchDegree(other.signature)
10941096
(// fast path: signatures are the same and neither denotation is a PolyType
10951097
// For polytypes, signatures alone do not tell us enough to be sure about matching.
1096-
d == Signature.FullMatch &&
1098+
d == FullMatch &&
10971099
!infoOrCompleter.isInstanceOf[PolyType] && !other.infoOrCompleter.isInstanceOf[PolyType]
10981100
||
1099-
d.ordinal >= Signature.ParamMatch.ordinal && info.matches(other.info))
1101+
d.ordinal >= ParamMatch.ordinal && info.matches(other.info))
11001102
}
11011103

11021104
def mapInherited(ownDenots: PreDenotation, prevDenots: PreDenotation, pre: Type)(implicit ctx: Context): SingleDenotation =

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,18 @@ case class Signature(paramsSig: List[TypeName], resSig: TypeName) {
7575
* `NoMatch` otherwise.
7676
* If the parameters are inconsistent, the result is always `NoMatch`.
7777
*/
78-
final def matchDegree(that: Signature)(implicit ctx: Context): MatchDegree =
78+
final def matchDegree(that: Signature)(implicit ctx: Context): MatchDegree = {
79+
import MatchDegree._
7980
if (consistentParams(that))
8081
if (resSig == that.resSig || isWildcard(resSig) || isWildcard(that.resSig)) FullMatch
8182
else if (!ctx.erasedTypes) ParamMatch
8283
else NoMatch
8384
else NoMatch
85+
}
8486

8587
/** Does this signature potentially clash with `that` ? */
8688
def clashes(that: Signature)(implicit ctx: Context): Boolean =
87-
matchDegree(that) == FullMatch
89+
matchDegree(that) == MatchDegree.FullMatch
8890

8991
/** name.toString == "" or name.toString == "_" */
9092
private def isWildcard(name: TypeName) = name.isEmpty || name == tpnme.WILDCARD
@@ -110,11 +112,6 @@ object Signature {
110112
enum MatchDegree {
111113
case NoMatch, ParamMatch, FullMatch
112114
}
113-
val NoMatch: MatchDegree.NoMatch.type = MatchDegree.NoMatch
114-
val ParamMatch: MatchDegree.ParamMatch.type = MatchDegree.ParamMatch
115-
val FullMatch: MatchDegree.FullMatch.type = MatchDegree.FullMatch
116-
// DOTTY todo: Replace previous three lines by `export MatchDegree._`
117-
// once 0.17 is released and #6729 is merged.
118115

119116
/** The signature of everything that's not a method, i.e. that has
120117
* a type different from PolyType, MethodType, or ExprType.
@@ -135,4 +132,4 @@ object Signature {
135132
assert(!resultType.isInstanceOf[ExprType])
136133
apply(Nil, sigName(resultType, isJava))
137134
}
138-
}
135+
}

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,13 +2150,14 @@ object messages {
21502150
val msg: String = {
21512151
def nameAnd = if (decl.name != previousDecl.name) " name and" else ""
21522152
val details = if (decl.isRealMethod && previousDecl.isRealMethod) {
2153+
import Signature.MatchDegree._
21532154
// compare the signatures when both symbols represent methods
21542155
decl.signature.matchDegree(previousDecl.signature) match {
2155-
case Signature.NoMatch =>
2156+
case NoMatch =>
21562157
"" // shouldn't be reachable
2157-
case Signature.ParamMatch =>
2158+
case ParamMatch =>
21582159
"have matching parameter types."
2159-
case Signature.FullMatch =>
2160+
case FullMatch =>
21602161
i"have the same$nameAnd type after erasure."
21612162
}
21622163
} else ""

0 commit comments

Comments
 (0)