@@ -468,9 +468,22 @@ object Denotations {
468
468
preferSym(sym1, sym2) &&
469
469
info1.overrides(info2, sym1.matchNullaryLoosely || sym2.matchNullaryLoosely, checkClassInfo = false )
470
470
471
+ /** `sym1` comes before `sym2` in the ranking
472
+ * 1. Non-bridge methods
473
+ * 2. non-methods
474
+ * 3. bridges
475
+ * 4. NoSymbol
476
+ */
477
+ def preferMethod (sym1 : Symbol , sym2 : Symbol ): Boolean =
478
+ sym1.exists &&
479
+ (! sym2.exists
480
+ || sym2.is(Bridge ) && ! sym1.is(Bridge )
481
+ || sym1.is(Method ) && ! sym2.is(Method )
482
+ || sym1.info.isErroneous)
483
+
471
484
def handleDoubleDef : Denotation =
472
- if preferSymSimple (sym1, sym2) then denot1
473
- else if preferSymSimple (sym2, sym1) then denot2
485
+ if preferMethod (sym1, sym2) then denot1
486
+ else if preferMethod (sym2, sym1) then denot2
474
487
else MultiDenotation (denot1, denot2)
475
488
476
489
if (sym2Accessible && prefer(sym2, sym1, info2, info1)) denot2
@@ -481,15 +494,13 @@ object Denotations {
481
494
else if (sym2Accessible && sym1.exists && ! sym1Accessible) denot2
482
495
else if (isDoubleDef(sym1, sym2)) handleDoubleDef
483
496
else
484
- val sym =
485
- if (preferSym(sym2, sym1)) sym2
486
- else sym1
497
+ val sym = if preferSym(sym2, sym1) then sym2 else sym1
487
498
def jointRef (jointInfo : Type ) =
488
499
JointRefDenotation (sym, jointInfo, denot1.validFor & denot2.validFor, pre)
489
500
try jointRef(infoMeet(info1, info2, sym1, sym2, safeIntersection))
490
501
catch case ex : MergeError =>
491
- if preferSymSimple (sym2, sym1) then jointRef(info2)
492
- else if preferSymSimple (sym1, sym2) then jointRef(info1)
502
+ if preferMethod (sym2, sym1) then jointRef(info2)
503
+ else if preferMethod (sym1, sym2) then jointRef(info1)
493
504
else if pre.widen.classSymbol.is(Scala2x ) || migrateTo3 then
494
505
jointRef(info1)
495
506
// follow Scala2 linearization -
0 commit comments