@@ -269,52 +269,49 @@ object Denotations {
269
269
}
270
270
case denot1 : SingleDenotation =>
271
271
if (denot1 eq denot2) denot1
272
- else {
272
+ else if (denot1.matches(denot2)) {
273
273
val info1 = denot1.info
274
274
val info2 = denot2.info
275
- if (denot1.signature.matches(denot2.signature) &&
276
- denot1.info.matches(denot2.info)) {
277
- val sym1 = denot1.symbol
278
- val sym2 = denot2.symbol
279
- val sym2Accessible = sym2.isAccessibleFrom(pre)
280
-
281
- /** Does `sym1` come before `sym2` in the linearization of `pre`? */
282
- def precedes (sym1 : Symbol , sym2 : Symbol ) = {
283
- def precedesIn (bcs : List [ClassSymbol ]): Boolean = bcs match {
284
- case bc :: bcs1 => (sym1 eq bc) || ! (sym2 eq bc) && precedesIn(bcs1)
285
- case Nil => true
286
- }
287
- sym1.derivesFrom(sym2) ||
288
- ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
275
+ val sym1 = denot1.symbol
276
+ val sym2 = denot2.symbol
277
+ val sym2Accessible = sym2.isAccessibleFrom(pre)
278
+
279
+ /** Does `sym1` come before `sym2` in the linearization of `pre`? */
280
+ def precedes (sym1 : Symbol , sym2 : Symbol ) = {
281
+ def precedesIn (bcs : List [ClassSymbol ]): Boolean = bcs match {
282
+ case bc :: bcs1 => (sym1 eq bc) || ! (sym2 eq bc) && precedesIn(bcs1)
283
+ case Nil => true
289
284
}
285
+ sym1.derivesFrom(sym2) ||
286
+ ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
287
+ }
290
288
291
- /** Preference according to partial pre-order (isConcrete, precedes) */
292
- def preferSym (sym1 : Symbol , sym2 : Symbol ) =
293
- sym1.eq(sym2) ||
294
- sym1.isAsConcrete(sym2) &&
295
- (! sym2.isAsConcrete(sym1) || precedes(sym1.owner, sym2.owner))
289
+ /** Preference according to partial pre-order (isConcrete, precedes) */
290
+ def preferSym (sym1 : Symbol , sym2 : Symbol ) =
291
+ sym1.eq(sym2) ||
292
+ sym1.isAsConcrete(sym2) &&
293
+ (! sym2.isAsConcrete(sym1) || precedes(sym1.owner, sym2.owner))
296
294
297
- /** Sym preference provided types also override */
298
- def prefer (sym1 : Symbol , sym2 : Symbol , info1 : Type , info2 : Type ) =
299
- preferSym(sym1, sym2) && info1.overrides(info2)
295
+ /** Sym preference provided types also override */
296
+ def prefer (sym1 : Symbol , sym2 : Symbol , info1 : Type , info2 : Type ) =
297
+ preferSym(sym1, sym2) && info1.overrides(info2)
300
298
301
- if (sym2Accessible && prefer(sym2, sym1, info2, info1)) denot2
299
+ if (sym2Accessible && prefer(sym2, sym1, info2, info1)) denot2
300
+ else {
301
+ val sym1Accessible = sym1.isAccessibleFrom(pre)
302
+ if (sym1Accessible && prefer(sym1, sym2, info1, info2)) denot1
303
+ else if (sym1Accessible && sym2.exists && ! sym2Accessible) denot1
304
+ else if (sym2Accessible && sym1.exists && ! sym1Accessible) denot2
302
305
else {
303
- val sym1Accessible = sym1.isAccessibleFrom(pre)
304
- if (sym1Accessible && prefer(sym1, sym2, info1, info2)) denot1
305
- else if (sym1Accessible && sym2.exists && ! sym2Accessible) denot1
306
- else if (sym2Accessible && sym1.exists && ! sym1Accessible) denot2
307
- else {
308
- val sym =
309
- if (! sym1.exists) sym2
310
- else if (! sym2.exists) sym1
311
- else if (preferSym(sym2, sym1)) sym2
312
- else sym1
313
- new JointRefDenotation (sym, info1 & info2, denot1.validFor & denot2.validFor)
314
- }
306
+ val sym =
307
+ if (! sym1.exists) sym2
308
+ else if (! sym2.exists) sym1
309
+ else if (preferSym(sym2, sym1)) sym2
310
+ else sym1
311
+ new JointRefDenotation (sym, info1 & info2, denot1.validFor & denot2.validFor)
315
312
}
316
- } else NoDenotation
317
- }
313
+ }
314
+ } else NoDenotation
318
315
}
319
316
320
317
if (this eq that) this
@@ -472,14 +469,16 @@ object Denotations {
472
469
473
470
def atSignature (sig : Signature , site : Type , relaxed : Boolean )(implicit ctx : Context ): SingleDenotation = {
474
471
val situated = if (site == NoPrefix ) this else asSeenFrom(site)
475
- val matches =
476
- if (relaxed) sig.matches(situated.signature)
477
- else sig.matchesFully(situated.signature)
472
+ val matches = sig.matchDegree(situated.signature) >=
473
+ (if (relaxed) Signature .ParamMatch else Signature .FullMatch )
478
474
if (matches) this else NoDenotation
479
475
}
480
476
481
- def matches (other : SingleDenotation )(implicit ctx : Context ): Boolean =
482
- signature.matches(other.signature) && info.matches(other.info)
477
+ def matches (other : SingleDenotation )(implicit ctx : Context ): Boolean = {
478
+ val d = signature.matchDegree(other.signature)
479
+ d == Signature .FullMatch ||
480
+ d >= Signature .ParamMatch && info.matches(other.info)
481
+ }
483
482
484
483
// ------ Forming types -------------------------------------------
485
484
@@ -788,7 +787,7 @@ object Denotations {
788
787
final def toDenot (pre : Type )(implicit ctx : Context ): Denotation = this
789
788
final def containsSym (sym : Symbol ): Boolean = hasUniqueSym && (symbol eq sym)
790
789
final def containsSig (sig : Signature )(implicit ctx : Context ) =
791
- exists && ( signature matches sig)
790
+ exists && signature.matchDegree( sig) >= Signature . ParamMatch
792
791
final def filterWithPredicate (p : SingleDenotation => Boolean ): SingleDenotation =
793
792
if (p(this )) this else NoDenotation
794
793
final def filterDisjoint (denots : PreDenotation )(implicit ctx : Context ): SingleDenotation =
0 commit comments