@@ -125,8 +125,9 @@ object Denotations {
125125
126126 /** Resolve overloaded denotation to pick the one with the given signature
127127 * when seen from prefix `site`.
128+ * @param relaxed When true, consider only parameter signatures for a match.
128129 */
129- def atSignature (sig : Signature , site : Type = NoPrefix )(implicit ctx : Context ): SingleDenotation
130+ def atSignature (sig : Signature , site : Type = NoPrefix , relaxed : Boolean = false )(implicit ctx : Context ): SingleDenotation
130131
131132 /** The variant of this denotation that's current in the given context, or
132133 * `NotDefinedHereDenotation` if this denotation does not exist at current phase, but
@@ -221,7 +222,7 @@ object Denotations {
221222 */
222223 def matchingDenotation (site : Type , targetType : Type )(implicit ctx : Context ): SingleDenotation =
223224 if (isOverloaded)
224- atSignature(targetType.signature, site).matchingDenotation(site, targetType)
225+ atSignature(targetType.signature, site, relaxed = true ).matchingDenotation(site, targetType)
225226 else if (exists && ! site.memberInfo(symbol).matchesLoosely(targetType))
226227 NoDenotation
227228 else
@@ -268,7 +269,7 @@ object Denotations {
268269 }
269270 case denot1 : SingleDenotation =>
270271 if (denot1 eq denot2) denot1
271- else if (denot1.signature matches denot2.signature ) {
272+ else if (denot1.matches( denot2) ) {
272273 val info1 = denot1.info
273274 val info2 = denot2.info
274275 val sym1 = denot1.symbol
@@ -282,14 +283,14 @@ object Denotations {
282283 case Nil => true
283284 }
284285 sym1.derivesFrom(sym2) ||
285- ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
286+ ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
286287 }
287288
288289 /** Preference according to partial pre-order (isConcrete, precedes) */
289290 def preferSym (sym1 : Symbol , sym2 : Symbol ) =
290291 sym1.eq(sym2) ||
291- sym1.isAsConcrete(sym2) &&
292- (! sym2.isAsConcrete(sym1) || precedes(sym1.owner, sym2.owner))
292+ sym1.isAsConcrete(sym2) &&
293+ (! sym2.isAsConcrete(sym1) || precedes(sym1.owner, sym2.owner))
293294
294295 /** Sym preference provided types also override */
295296 def prefer (sym1 : Symbol , sym2 : Symbol , info1 : Type , info2 : Type ) =
@@ -310,8 +311,7 @@ object Denotations {
310311 new JointRefDenotation (sym, info1 & info2, denot1.validFor & denot2.validFor)
311312 }
312313 }
313- }
314- else NoDenotation
314+ } else NoDenotation
315315 }
316316
317317 if (this eq that) this
@@ -333,7 +333,7 @@ object Denotations {
333333 def | (that : Denotation , pre : Type )(implicit ctx : Context ): Denotation = {
334334
335335 def unionDenot (denot1 : SingleDenotation , denot2 : SingleDenotation ): Denotation =
336- if (denot1.signature matches denot2.signature ) {
336+ if (denot1.matches( denot2) ) {
337337 val sym1 = denot1.symbol
338338 val sym2 = denot2.symbol
339339 val info1 = denot1.info
@@ -396,8 +396,8 @@ object Denotations {
396396 final def validFor = denot1.validFor & denot2.validFor
397397 final def isType = false
398398 final def signature (implicit ctx : Context ) = Signature .OverloadedSignature
399- def atSignature (sig : Signature , site : Type )(implicit ctx : Context ): SingleDenotation =
400- denot1.atSignature(sig, site) orElse denot2.atSignature(sig, site)
399+ def atSignature (sig : Signature , site : Type , relaxed : Boolean )(implicit ctx : Context ): SingleDenotation =
400+ denot1.atSignature(sig, site, relaxed ) orElse denot2.atSignature(sig, site, relaxed )
401401 def currentIfExists (implicit ctx : Context ): Denotation =
402402 derivedMultiDenotation(denot1.currentIfExists, denot2.currentIfExists)
403403 def current (implicit ctx : Context ): Denotation =
@@ -467,9 +467,11 @@ object Denotations {
467467 def accessibleFrom (pre : Type , superAccess : Boolean )(implicit ctx : Context ): Denotation =
468468 if (! symbol.exists || symbol.isAccessibleFrom(pre, superAccess)) this else NoDenotation
469469
470- def atSignature (sig : Signature , site : Type )(implicit ctx : Context ): SingleDenotation = {
470+ def atSignature (sig : Signature , site : Type , relaxed : Boolean )(implicit ctx : Context ): SingleDenotation = {
471471 val situated = if (site == NoPrefix ) this else asSeenFrom(site)
472- if (sig matches situated.signature) this else NoDenotation
472+ val matches = sig.matchDegree(situated.signature) >=
473+ (if (relaxed) Signature .ParamMatch else Signature .FullMatch )
474+ if (matches) this else NoDenotation
473475 }
474476
475477 // ------ Forming types -------------------------------------------
@@ -778,12 +780,15 @@ object Denotations {
778780 final def last = this
779781 final def toDenot (pre : Type )(implicit ctx : Context ): Denotation = this
780782 final def containsSym (sym : Symbol ): Boolean = hasUniqueSym && (symbol eq sym)
781- final def containsSig (sig : Signature )(implicit ctx : Context ) =
782- exists && (signature matches sig)
783+ final def matches (other : SingleDenotation )(implicit ctx : Context ): Boolean = {
784+ val d = signature.matchDegree(other.signature)
785+ d == Signature .FullMatch ||
786+ d >= Signature .ParamMatch && info.matches(other.info)
787+ }
783788 final def filterWithPredicate (p : SingleDenotation => Boolean ): SingleDenotation =
784789 if (p(this )) this else NoDenotation
785790 final def filterDisjoint (denots : PreDenotation )(implicit ctx : Context ): SingleDenotation =
786- if (denots.exists && denots.containsSig(signature )) NoDenotation else this
791+ if (denots.exists && denots.matches( this )) NoDenotation else this
787792 def mapInherited (ownDenots : PreDenotation , prevDenots : PreDenotation , pre : Type )(implicit ctx : Context ): SingleDenotation =
788793 if (hasUniqueSym && prevDenots.containsSym(symbol)) NoDenotation
789794 else if (isType) filterDisjoint(ownDenots).asSeenFrom(pre)
@@ -872,7 +877,7 @@ object Denotations {
872877 def containsSym (sym : Symbol ): Boolean
873878
874879 /** Group contains a denotation with given signature */
875- def containsSig ( sig : Signature )(implicit ctx : Context ): Boolean
880+ def matches ( other : SingleDenotation )(implicit ctx : Context ): Boolean
876881
877882 /** Keep only those denotations in this group which satisfy predicate `p`. */
878883 def filterWithPredicate (p : SingleDenotation => Boolean ): PreDenotation
@@ -933,8 +938,8 @@ object Denotations {
933938 (denots1 toDenot pre) & (denots2 toDenot pre, pre)
934939 def containsSym (sym : Symbol ) =
935940 (denots1 containsSym sym) || (denots2 containsSym sym)
936- def containsSig ( sig : Signature )(implicit ctx : Context ) =
937- ( denots1 containsSig sig ) || ( denots2 containsSig sig )
941+ def matches ( other : SingleDenotation )(implicit ctx : Context ): Boolean =
942+ denots1.matches(other ) || denots2.matches(other )
938943 def filterWithPredicate (p : SingleDenotation => Boolean ): PreDenotation =
939944 derivedUnion(denots1 filterWithPredicate p, denots2 filterWithPredicate p)
940945 def filterDisjoint (denots : PreDenotation )(implicit ctx : Context ): PreDenotation =
0 commit comments