@@ -407,7 +407,7 @@ object Denotations {
407407 }
408408
409409 /** Try to merge single-denotations. */
410- def mergeSingleDenot (denot1 : SingleDenotation , denot2 : SingleDenotation ): Denotation = {
410+ def mergeSingleDenot (denot1 : SingleDenotation , denot2 : SingleDenotation ): Denotation =
411411 val info1 = denot1.info
412412 val info2 = denot2.info
413413 val sym1 = denot1.symbol
@@ -474,34 +474,28 @@ object Denotations {
474474 else MultiDenotation (denot1, denot2)
475475
476476 if (sym2Accessible && prefer(sym2, sym1, info2, info1)) denot2
477- else {
477+ else
478478 val sym1Accessible = sym1.isAccessibleFrom(pre)
479479 if (sym1Accessible && prefer(sym1, sym2, info1, info2)) denot1
480480 else if (sym1Accessible && sym2.exists && ! sym2Accessible) denot1
481481 else if (sym2Accessible && sym1.exists && ! sym1Accessible) denot2
482482 else if (isDoubleDef(sym1, sym2)) handleDoubleDef
483- else {
483+ else
484484 val sym =
485485 if (preferSym(sym2, sym1)) sym2
486486 else sym1
487- val jointInfo =
488- try infoMeet(info1, info2, sym1, sym2, safeIntersection)
489- catch {
490- case ex : MergeError =>
491- // TODO: this picks one type over the other whereas it might be better
492- // to return a MultiDenotation instead. But doing so would affect lots of
493- // things, starting with the return type of this method.
494- if (preferSym(sym2, sym1)) info2
495- else if (preferSym(sym1, sym2)) info1
496- else if (pre.widen.classSymbol.is(Scala2x ) || migrateTo3)
497- info1 // follow Scala2 linearization -
487+ def jointRef (jointInfo : Type ) =
488+ JointRefDenotation (sym, jointInfo, denot1.validFor & denot2.validFor, pre)
489+ try jointRef(infoMeet(info1, info2, sym1, sym2, safeIntersection))
490+ catch case ex : MergeError =>
491+ if preferSymSimple(sym2, sym1) then jointRef(info2)
492+ else if preferSymSimple(sym1, sym2) then jointRef(info1)
493+ else if pre.widen.classSymbol.is(Scala2x ) || migrateTo3 then
494+ jointRef(info1)
495+ // follow Scala2 linearization -
498496 // compare with way merge is performed in SymDenotation#computeMembersNamed
499- else throw new MergeError (ex.sym1, ex.sym2, ex.tp1, ex.tp2, pre)
500- }
501- new JointRefDenotation (sym, jointInfo, denot1.validFor & denot2.validFor, pre)
502- }
503- }
504- }
497+ else MultiDenotation (denot1, denot2)
498+ end mergeSingleDenot
505499
506500 if (this eq that) this
507501 else if (! this .exists) that
0 commit comments