diff options
author | Martin Odersky <odersky@gmail.com> | 2016-05-02 15:58:44 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-05-18 19:43:22 +0200 |
commit | fe5f4f3963d2d6b2f6514a362fb312bc2e7d7f94 (patch) | |
tree | 1e0ab57e191801923ff0b6aec73b9e29a5027de5 | |
parent | f722de7c6131b544345dbc6745b5d219de5831e7 (diff) | |
download | dotty-fe5f4f3963d2d6b2f6514a362fb312bc2e7d7f94.tar.gz dotty-fe5f4f3963d2d6b2f6514a362fb312bc2e7d7f94.tar.bz2 dotty-fe5f4f3963d2d6b2f6514a362fb312bc2e7d7f94.zip |
Revert: ResolveOverloaded should handle alternatives that are the same TermRef
This happens once we do not merge methods with the same signature coming
from the same class. (reverted from commit 83262d090a98e2374c9b3e5a1480892397d695d3)
This case no longer applies as such a situation will now give a MergeError instead.
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 4f7a1c220..390ecaee9 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -867,6 +867,8 @@ trait Applications extends Compatibility { self: Typer => */ def isAsGood(alt1: TermRef, alt2: TermRef)(implicit ctx: Context): Boolean = track("isAsGood") { ctx.traceIndented(i"isAsGood($alt1, $alt2)", overload) { + assert(alt1 ne alt2) + /** Is class or module class `sym1` derived from class or module class `sym2`? * Module classes also inherit the relationship from their companions. */ @@ -973,20 +975,14 @@ trait Applications extends Compatibility { self: Typer => bestSoFar } val best = winner(alt, alts1) - // A tricky corner case is where we have two methods that have the same signature - // when seen from a particulatr prefix. In that case the TermRefs of two - // alternatives are identical. Hence, we have to make sure (using `altSeen`) that we - // eliminate only one alternative that's identical to `best`. - // A test case is in neg/i1240.scala - def asGood(alts: List[TermRef], altSeen: Boolean): List[TermRef] = alts match { + def asGood(alts: List[TermRef]): List[TermRef] = alts match { case alt :: alts1 => - if (!altSeen && (alt eq best)) asGood(alts1, altSeen = true) - else if (!isAsGood(alt, best)) asGood(alts1, altSeen) - else alt :: asGood(alts1, altSeen) + if ((alt eq best) || !isAsGood(alt, best)) asGood(alts1) + else alt :: asGood(alts1) case nil => Nil } - best :: asGood(alts, altSeen = false) + best :: asGood(alts) } } |