@@ -60,12 +60,7 @@ case class Signature(paramsSig: List[ParamSig], resSig: TypeName) {
60
60
@ tailrec def loop (names1 : List [ParamSig ], names2 : List [ParamSig ]): Boolean =
61
61
if (names1.isEmpty) names2.isEmpty
62
62
else ! names2.isEmpty && consistent(names1.head, names2.head) && loop(names1.tail, names2.tail)
63
- if (ctx.erasedTypes && (this == NotAMethod ) != (that == NotAMethod ))
64
- false // After erasure, we allow fields and parameterless methods with the same name.
65
- // This is needed to allow both a module field and a bridge method for an abstract val.
66
- // Test case is patmatch-classtag.scala
67
- else
68
- loop(this .paramsSig, that.paramsSig)
63
+ loop(this .paramsSig, that.paramsSig)
69
64
}
70
65
71
66
/** `that` signature, but keeping all corresponding parts of `this` signature. */
@@ -87,23 +82,27 @@ case class Signature(paramsSig: List[ParamSig], resSig: TypeName) {
87
82
/** The degree to which this signature matches `that`.
88
83
* If parameter signatures are consistent and result types names match (i.e. they are the same
89
84
* or one is a wildcard), the result is `FullMatch`.
90
- * If only the parameter signatures are consistent, the result is `ParamMatch` before erasure and
91
- * `NoMatch` otherwise.
85
+ * If only the parameter signatures are consistent, the result is either
86
+ * `MethodNotAMethodMatch` (if one side is a method signature and the other isn't),
87
+ * or `ParamMatch`.
92
88
* If the parameters are inconsistent, the result is always `NoMatch`.
93
89
*/
94
90
final def matchDegree (that : Signature )(implicit ctx : Context ): MatchDegree =
95
- if (consistentParams(that))
96
- if (resSig == that.resSig || isWildcard(resSig) || isWildcard(that.resSig)) FullMatch
97
- else if (! ctx.erasedTypes) ParamMatch
98
- else NoMatch
99
- else NoMatch
91
+ if consistentParams(that) then
92
+ if resSig == that.resSig || isWildcard(resSig) || isWildcard(that.resSig) then
93
+ FullMatch
94
+ else if (this == NotAMethod ) != (that == NotAMethod ) then
95
+ MethodNotAMethodMatch
96
+ else
97
+ ParamMatch
98
+ else
99
+ NoMatch
100
100
101
101
/** Does this signature potentially clash with `that` ? */
102
102
def clashes (that : Signature )(implicit ctx : Context ): Boolean =
103
103
matchDegree(that) == FullMatch
104
104
105
- /** name.toString == "" or name.toString == "_" */
106
- private def isWildcard (name : TypeName ) = name.isEmpty || name == tpnme.WILDCARD
105
+ private def isWildcard (name : TypeName ) = name == tpnme.WILDCARD
107
106
108
107
/** Construct a signature by prepending the signature names of the given `params`
109
108
* to the parameter part of this signature.
@@ -136,7 +135,17 @@ object Signature {
136
135
// small values, so the performance hit should be minimal.
137
136
138
137
enum MatchDegree {
139
- case NoMatch , ParamMatch , FullMatch
138
+ /** The signatures are unrelated. */
139
+ case NoMatch
140
+ /** The parameter signatures are equivalent. */
141
+ case ParamMatch
142
+ /** Both signatures have no parameters, one is a method and the other isn't.
143
+ *
144
+ * @see NotAMethod
145
+ */
146
+ case MethodNotAMethodMatch
147
+ /** The parameter and result type signatures are equivalent. */
148
+ case FullMatch
140
149
}
141
150
export MatchDegree ._
142
151
0 commit comments