From a1e615c9253d9caad1385e163e271510c3c798b5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 14 Mar 2007 10:40:43 +0000 Subject: re-fixed bug 1000 --- src/compiler/scala/tools/nsc/symtab/Types.scala | 8 ++++++-- src/compiler/scala/tools/nsc/transform/Erasure.scala | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 487cfb312c..3f82afde11 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -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 } diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index d0150971a1..72639afa6f 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -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 } -- cgit v1.2.3