@@ -60,12 +60,7 @@ case class Signature(paramsSig: List[ParamSig], resSig: TypeName) {
6060 @ tailrec def loop (names1 : List [ParamSig ], names2 : List [ParamSig ]): Boolean =
6161 if (names1.isEmpty) names2.isEmpty
6262 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)
6964 }
7065
7166 /** `that` signature, but keeping all corresponding parts of `this` signature. */
@@ -87,23 +82,27 @@ case class Signature(paramsSig: List[ParamSig], resSig: TypeName) {
8782 /** The degree to which this signature matches `that`.
8883 * If parameter signatures are consistent and result types names match (i.e. they are the same
8984 * 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`.
9288 * If the parameters are inconsistent, the result is always `NoMatch`.
9389 */
9490 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
100100
101101 /** Does this signature potentially clash with `that` ? */
102102 def clashes (that : Signature )(implicit ctx : Context ): Boolean =
103103 matchDegree(that) == FullMatch
104104
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
107106
108107 /** Construct a signature by prepending the signature names of the given `params`
109108 * to the parameter part of this signature.
@@ -136,7 +135,17 @@ object Signature {
136135 // small values, so the performance hit should be minimal.
137136
138137 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
140149 }
141150 export MatchDegree ._
142151
0 commit comments