re-fixed bug 1000

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@10334 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
odersky 2007-03-14 10:40:43 +00:00
parent 30db5ce75c
commit 502867dfc8
2 changed files with 18 additions and 2 deletions

View File

@ -305,6 +305,10 @@ trait Types requires SymbolTable {
*/
def matches(that: Type): boolean = matchesType(this, that, !phase.erasedTypes)
/** Same as matches, except that non-method types are always assumed to match.
*/
def looselyMatches(that: Type): boolean = matchesType(this, that, true)
/** The shortest sorted upwards closed array of types that contains
* this type as first element.
*
@ -447,7 +451,7 @@ trait Types requires SymbolTable {
member.owner != sym.owner &&
!sym.hasFlag(PRIVATE) && {
if (self eq null) self = this.narrow;
matchesType(self.memberType(member), self.memberType(sym), !phase.erasedTypes)
(self.memberType(member) matches self.memberType(sym))
})) {
members = newScope(List(member, sym))
}
@ -458,7 +462,7 @@ trait Types requires SymbolTable {
prevEntry.sym.owner != sym.owner &&
!sym.hasFlag(PRIVATE) && {
if (self eq null) self = this.narrow;
matchesType(self.memberType(prevEntry.sym), self.memberType(sym), !phase.erasedTypes)
(self.memberType(prevEntry.sym) matches self.memberType(sym))
})) {
prevEntry = members lookupNextEntry prevEntry
}

View File

@ -484,6 +484,18 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
copy.Match(tree1, selector, cases map adaptCase)
case Try(block, catches, finalizer) =>
copy.Try(tree1, adaptBranch(block), catches map adaptCase, finalizer)
case Ident(_) | Select(_, _) =>
if (tree1.symbol hasFlag OVERLOADED) {
val first = tree1.symbol.alternatives.head
val sym1 = tree1.symbol.filter {
alt => alt == first || !(first.tpe looselyMatches alt.tpe)
}
if (tree.symbol ne sym1) {
tree1.symbol = sym1
tree1.tpe = sym1.tpe
}
}
tree1
case _ =>
tree1
}