@@ -273,35 +273,34 @@ object Denotations {
273273
274274 def unionDenot (denot1 : SingleDenotation , denot2 : SingleDenotation ): Denotation =
275275 if (denot1.signature matches denot2.signature) {
276+ val sym1 = denot1.symbol
277+ val sym2 = denot2.symbol
276278 val info1 = denot1.info
277279 val info2 = denot2.info
278- val sym2 = denot2.symbol
279- def sym2Accessible = sym2.isAccessibleFrom(pre)
280- if (info1 <:< info2 && sym2Accessible) denot2
280+ val sameSym = sym1 eq sym2
281+ if (sameSym && info1 <:< info2) denot2
282+ else if (sameSym && info2 <:< info1) denot1
281283 else {
282- val sym1 = denot1.symbol
283- def sym1Accessible = sym1.isAccessibleFrom(pre)
284- if (info2 <:< info1 && sym1Accessible) denot1
285- else {
286- val owner2 = if (sym2 ne NoSymbol ) sym2.owner else NoSymbol
287- /** Determine a symbol which is overridden by both sym1 and sym2.
288- * Preference is given to accessible symbols.
289- */
290- def lubSym (overrides : Iterator [Symbol ], previous : Symbol ): Symbol =
291- if (! overrides.hasNext) previous
292- else {
293- val candidate = overrides.next
294- if (owner2 derivesFrom candidate.owner)
295- if (candidate isAccessibleFrom pre) candidate
296- else lubSym(overrides, previous orElse candidate)
297- else
298- lubSym(overrides, previous)
299- }
300- new JointRefDenotation (
301- lubSym(sym1.allOverriddenSymbols, NoSymbol ),
302- info1 | info2,
303- denot1.validFor & denot2.validFor)
304- }
284+ val jointSym =
285+ if (sameSym) sym1
286+ else {
287+ val owner2 = if (sym2 ne NoSymbol ) sym2.owner else NoSymbol
288+ /** Determine a symbol which is overridden by both sym1 and sym2.
289+ * Preference is given to accessible symbols.
290+ */
291+ def lubSym (overrides : Iterator [Symbol ], previous : Symbol ): Symbol =
292+ if (! overrides.hasNext) previous
293+ else {
294+ val candidate = overrides.next
295+ if (owner2 derivesFrom candidate.owner)
296+ if (candidate isAccessibleFrom pre) candidate
297+ else lubSym(overrides, previous orElse candidate)
298+ else
299+ lubSym(overrides, previous)
300+ }
301+ lubSym(sym1.allOverriddenSymbols, NoSymbol )
302+ }
303+ new JointRefDenotation (jointSym, info1 | info2, denot1.validFor & denot2.validFor)
305304 }
306305 }
307306 else NoDenotation
@@ -335,7 +334,7 @@ object Denotations {
335334 final def info (implicit ctx : Context ) = infoOrCompleter
336335 final def validFor = denot1.validFor & denot2.validFor
337336 final def isType = false
338- def signature (implicit ctx : Context ) = multiHasNot( " signature " )
337+ final def signature (implicit ctx : Context ) = Signature . OverloadedSignature
339338 def atSignature (sig : Signature )(implicit ctx : Context ): SingleDenotation =
340339 denot1.atSignature(sig) orElse denot2.atSignature(sig)
341340 def current (implicit ctx : Context ): Denotation =
0 commit comments