@@ -22,35 +22,40 @@ import TypeErasure.sigName
22
22
* "scala.String".toTypeName)
23
23
*
24
24
* The signatures of non-method types are always `NotAMethod`.
25
+ *
26
+ * There are three kinds of "missing" parts of signatures:
27
+ *
28
+ * - tpnme.EMPTY Result type marker for NotAMethod and OverloadedSignature
29
+ * - tpnme.WILDCARD Arises from a Wildcard or error type
30
+ * - tpnme.Uninstantiated Arises from an uninstantiated type variable
25
31
*/
26
32
case class Signature (paramsSig : List [TypeName ], resSig : TypeName ) {
27
33
import Signature ._
28
34
29
- /** Does this signature coincide with that signature on their parameter parts? */
30
- final def sameParams (that : Signature ): Boolean = this .paramsSig == that.paramsSig
35
+ /** Two names are consistent if they are the same or one of them is tpnme.Uninstantiated */
36
+ private def consistent (name1 : TypeName , name2 : TypeName ) =
37
+ name1 == name2 || name1 == tpnme.Uninstantiated || name2 == tpnme.Uninstantiated
31
38
32
39
/** Does this signature coincide with that signature on their parameter parts?
33
40
* This is the case if all parameter names are _consistent_, i.e. they are either
34
41
* equal or on of them is tpnme.Uninstantiated.
35
42
*/
36
43
final def consistentParams (that : Signature ): Boolean = {
37
- def consistent (name1 : TypeName , name2 : TypeName ) =
38
- name1 == name2 || name1 == tpnme.Uninstantiated || name2 == tpnme.Uninstantiated
39
44
def loop (names1 : List [TypeName ], names2 : List [TypeName ]): Boolean =
40
45
if (names1.isEmpty) names2.isEmpty
41
46
else names2.nonEmpty && consistent(names1.head, names2.head) && loop(names1.tail, names2.tail)
42
47
loop(this .paramsSig, that.paramsSig)
43
48
}
44
49
45
50
/** The degree to which this signature matches `that`.
46
- * If both parameter and result type names match (i.e. they are the same
51
+ * If parameter names are consistent and result types names match (i.e. they are the same
47
52
* or one is a wildcard), the result is `FullMatch`.
48
- * If only the parameter names match , the result is `ParamMatch` before erasure and
53
+ * If only the parameter names are constistent , the result is `ParamMatch` before erasure and
49
54
* `NoMatch` otherwise.
50
- * If the parameters do not match , the result is always `NoMatch`.
55
+ * If the parameters are inconsistent , the result is always `NoMatch`.
51
56
*/
52
57
final def matchDegree (that : Signature )(implicit ctx : Context ): MatchDegree =
53
- if (sameParams (that))
58
+ if (consistentParams (that))
54
59
if (resSig == that.resSig || isWildcard(resSig) || isWildcard(that.resSig)) FullMatch
55
60
else if (! ctx.erasedTypes) ParamMatch
56
61
else NoMatch
0 commit comments