@@ -268,50 +268,52 @@ object Denotations {
268
268
}
269
269
case denot1 : SingleDenotation =>
270
270
if (denot1 eq denot2) denot1
271
- else if (denot1.signature matches denot2.signature) {
271
+ else {
272
272
val info1 = denot1.info
273
273
val info2 = denot2.info
274
- val sym1 = denot1.symbol
275
- val sym2 = denot2.symbol
276
- val sym2Accessible = sym2.isAccessibleFrom(pre)
277
-
278
- /** Does `sym1` come before `sym2` in the linearization of `pre`? */
279
- def precedes (sym1 : Symbol , sym2 : Symbol ) = {
280
- def precedesIn (bcs : List [ClassSymbol ]): Boolean = bcs match {
281
- case bc :: bcs1 => (sym1 eq bc) || ! (sym2 eq bc) && precedesIn(bcs1)
282
- case Nil => true
274
+ if (denot1.signature.matches(denot2.signature) &&
275
+ denot1.info.matches(denot2.info)) {
276
+ val sym1 = denot1.symbol
277
+ val sym2 = denot2.symbol
278
+ val sym2Accessible = sym2.isAccessibleFrom(pre)
279
+
280
+ /** Does `sym1` come before `sym2` in the linearization of `pre`? */
281
+ def precedes (sym1 : Symbol , sym2 : Symbol ) = {
282
+ def precedesIn (bcs : List [ClassSymbol ]): Boolean = bcs match {
283
+ case bc :: bcs1 => (sym1 eq bc) || ! (sym2 eq bc) && precedesIn(bcs1)
284
+ case Nil => true
285
+ }
286
+ sym1.derivesFrom(sym2) ||
287
+ ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
283
288
}
284
- sym1.derivesFrom(sym2) ||
285
- ! sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)
286
- }
287
289
288
- /** Preference according to partial pre-order (isConcrete, precedes) */
289
- def preferSym (sym1 : Symbol , sym2 : Symbol ) =
290
- sym1.eq(sym2) ||
291
- sym1.isAsConcrete(sym2) &&
292
- (! sym2.isAsConcrete(sym1) || precedes(sym1.owner, sym2.owner))
290
+ /** Preference according to partial pre-order (isConcrete, precedes) */
291
+ def preferSym (sym1 : Symbol , sym2 : Symbol ) =
292
+ sym1.eq(sym2) ||
293
+ sym1.isAsConcrete(sym2) &&
294
+ (! sym2.isAsConcrete(sym1) || precedes(sym1.owner, sym2.owner))
293
295
294
- /** Sym preference provided types also override */
295
- def prefer (sym1 : Symbol , sym2 : Symbol , info1 : Type , info2 : Type ) =
296
- preferSym(sym1, sym2) && info1.overrides(info2)
296
+ /** Sym preference provided types also override */
297
+ def prefer (sym1 : Symbol , sym2 : Symbol , info1 : Type , info2 : Type ) =
298
+ preferSym(sym1, sym2) && info1.overrides(info2)
297
299
298
- if (sym2Accessible && prefer(sym2, sym1, info2, info1)) denot2
299
- else {
300
- val sym1Accessible = sym1.isAccessibleFrom(pre)
301
- if (sym1Accessible && prefer(sym1, sym2, info1, info2)) denot1
302
- else if (sym1Accessible && sym2.exists && ! sym2Accessible) denot1
303
- else if (sym2Accessible && sym1.exists && ! sym1Accessible) denot2
300
+ if (sym2Accessible && prefer(sym2, sym1, info2, info1)) denot2
304
301
else {
305
- val sym =
306
- if (! sym1.exists) sym2
307
- else if (! sym2.exists) sym1
308
- else if (preferSym(sym2, sym1)) sym2
309
- else sym1
310
- new JointRefDenotation (sym, info1 & info2, denot1.validFor & denot2.validFor)
302
+ val sym1Accessible = sym1.isAccessibleFrom(pre)
303
+ if (sym1Accessible && prefer(sym1, sym2, info1, info2)) denot1
304
+ else if (sym1Accessible && sym2.exists && ! sym2Accessible) denot1
305
+ else if (sym2Accessible && sym1.exists && ! sym1Accessible) denot2
306
+ else {
307
+ val sym =
308
+ if (! sym1.exists) sym2
309
+ else if (! sym2.exists) sym1
310
+ else if (preferSym(sym2, sym1)) sym2
311
+ else sym1
312
+ new JointRefDenotation (sym, info1 & info2, denot1.validFor & denot2.validFor)
313
+ }
311
314
}
312
- }
315
+ } else NoDenotation
313
316
}
314
- else NoDenotation
315
317
}
316
318
317
319
if (this eq that) this
@@ -333,7 +335,7 @@ object Denotations {
333
335
def | (that : Denotation , pre : Type )(implicit ctx : Context ): Denotation = {
334
336
335
337
def unionDenot (denot1 : SingleDenotation , denot2 : SingleDenotation ): Denotation =
336
- if (denot1.signature matches denot2.signature ) {
338
+ if (denot1.matches( denot2) ) {
337
339
val sym1 = denot1.symbol
338
340
val sym2 = denot2.symbol
339
341
val info1 = denot1.info
@@ -472,6 +474,9 @@ object Denotations {
472
474
if (sig matches situated.signature) this else NoDenotation
473
475
}
474
476
477
+ def matches (other : SingleDenotation )(implicit ctx : Context ): Boolean =
478
+ signature.matches(other.signature) && info.matches(other.info)
479
+
475
480
// ------ Forming types -------------------------------------------
476
481
477
482
/** The TypeRef representing this type denotation at its original location. */
0 commit comments