@@ -125,8 +125,9 @@ object Denotations {
125
125
126
126
/** Resolve overloaded denotation to pick the one with the given signature
127
127
* when seen from prefix `site`.
128
+ * @param relaxed When true, consider only parameter signatures for a match.
128
129
*/
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
130
131
131
132
/** The variant of this denotation that's current in the given context, or
132
133
* `NotDefinedHereDenotation` if this denotation does not exist at current phase, but
@@ -221,7 +222,7 @@ object Denotations {
221
222
*/
222
223
def matchingDenotation (site : Type , targetType : Type )(implicit ctx : Context ): SingleDenotation =
223
224
if (isOverloaded)
224
- atSignature(targetType.signature, site).matchingDenotation(site, targetType)
225
+ atSignature(targetType.signature, site, relaxed = true ).matchingDenotation(site, targetType)
225
226
else if (exists && ! site.memberInfo(symbol).matchesLoosely(targetType))
226
227
NoDenotation
227
228
else
@@ -268,7 +269,7 @@ object Denotations {
268
269
}
269
270
case denot1 : SingleDenotation =>
270
271
if (denot1 eq denot2) denot1
271
- else if (denot1.signature matches denot2.signature ) {
272
+ else if (denot1.matches( denot2) ) {
272
273
val info1 = denot1.info
273
274
val info2 = denot2.info
274
275
val sym1 = denot1.symbol
@@ -282,14 +283,14 @@ object Denotations {
282
283
case Nil => true
283
284
}
284
285
sym1.derivesFrom(sym2) ||
285
- ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
286
+ ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
286
287
}
287
288
288
289
/** Preference according to partial pre-order (isConcrete, precedes) */
289
290
def preferSym (sym1 : Symbol , sym2 : Symbol ) =
290
291
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))
293
294
294
295
/** Sym preference provided types also override */
295
296
def prefer (sym1 : Symbol , sym2 : Symbol , info1 : Type , info2 : Type ) =
@@ -310,8 +311,7 @@ object Denotations {
310
311
new JointRefDenotation (sym, info1 & info2, denot1.validFor & denot2.validFor)
311
312
}
312
313
}
313
- }
314
- else NoDenotation
314
+ } else NoDenotation
315
315
}
316
316
317
317
if (this eq that) this
@@ -333,7 +333,7 @@ object Denotations {
333
333
def | (that : Denotation , pre : Type )(implicit ctx : Context ): Denotation = {
334
334
335
335
def unionDenot (denot1 : SingleDenotation , denot2 : SingleDenotation ): Denotation =
336
- if (denot1.signature matches denot2.signature ) {
336
+ if (denot1.matches( denot2) ) {
337
337
val sym1 = denot1.symbol
338
338
val sym2 = denot2.symbol
339
339
val info1 = denot1.info
@@ -396,8 +396,8 @@ object Denotations {
396
396
final def validFor = denot1.validFor & denot2.validFor
397
397
final def isType = false
398
398
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 )
401
401
def currentIfExists (implicit ctx : Context ): Denotation =
402
402
derivedMultiDenotation(denot1.currentIfExists, denot2.currentIfExists)
403
403
def current (implicit ctx : Context ): Denotation =
@@ -467,9 +467,11 @@ object Denotations {
467
467
def accessibleFrom (pre : Type , superAccess : Boolean )(implicit ctx : Context ): Denotation =
468
468
if (! symbol.exists || symbol.isAccessibleFrom(pre, superAccess)) this else NoDenotation
469
469
470
- def atSignature (sig : Signature , site : Type )(implicit ctx : Context ): SingleDenotation = {
470
+ def atSignature (sig : Signature , site : Type , relaxed : Boolean )(implicit ctx : Context ): SingleDenotation = {
471
471
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
473
475
}
474
476
475
477
// ------ Forming types -------------------------------------------
@@ -778,12 +780,15 @@ object Denotations {
778
780
final def last = this
779
781
final def toDenot (pre : Type )(implicit ctx : Context ): Denotation = this
780
782
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
+ }
783
788
final def filterWithPredicate (p : SingleDenotation => Boolean ): SingleDenotation =
784
789
if (p(this )) this else NoDenotation
785
790
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
787
792
def mapInherited (ownDenots : PreDenotation , prevDenots : PreDenotation , pre : Type )(implicit ctx : Context ): SingleDenotation =
788
793
if (hasUniqueSym && prevDenots.containsSym(symbol)) NoDenotation
789
794
else if (isType) filterDisjoint(ownDenots).asSeenFrom(pre)
@@ -872,7 +877,7 @@ object Denotations {
872
877
def containsSym (sym : Symbol ): Boolean
873
878
874
879
/** 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
876
881
877
882
/** Keep only those denotations in this group which satisfy predicate `p`. */
878
883
def filterWithPredicate (p : SingleDenotation => Boolean ): PreDenotation
@@ -933,8 +938,8 @@ object Denotations {
933
938
(denots1 toDenot pre) & (denots2 toDenot pre, pre)
934
939
def containsSym (sym : Symbol ) =
935
940
(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 )
938
943
def filterWithPredicate (p : SingleDenotation => Boolean ): PreDenotation =
939
944
derivedUnion(denots1 filterWithPredicate p, denots2 filterWithPredicate p)
940
945
def filterDisjoint (denots : PreDenotation )(implicit ctx : Context ): PreDenotation =
0 commit comments