diff options
author | Martin Odersky <odersky@gmail.com> | 2005-06-17 17:34:13 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-06-17 17:34:13 +0000 |
commit | 97b285c569217f2134a33670022418bf4b6689ec (patch) | |
tree | 36f0937864565cec165204eac3a76cbcf3deb16b | |
parent | a9b4163417d4f7e4dda571ac7f2ce6db7c8c63a0 (diff) | |
download | scala-97b285c569217f2134a33670022418bf4b6689ec.tar.gz scala-97b285c569217f2134a33670022418bf4b6689ec.tar.bz2 scala-97b285c569217f2134a33670022418bf4b6689ec.zip |
*** empty log message ***
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Types.scala | 25 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/typechecker/RefChecks.scala | 5 |
2 files changed, 16 insertions, 14 deletions
diff --git a/sources/scala/tools/nsc/symtab/Types.scala b/sources/scala/tools/nsc/symtab/Types.scala index f0b46afdc2..d5cf7102d6 100755 --- a/sources/scala/tools/nsc/symtab/Types.scala +++ b/sources/scala/tools/nsc/symtab/Types.scala @@ -57,8 +57,7 @@ abstract class Types: SymbolTable { /** Map to a this type which is a subtype of this type. */ - def narrow: Type = - refinedType(List(this), commonOwner(this), EmptyScope).narrow; + def narrow: Type = refinedType(List(this), commonOwner(this), EmptyScope).narrow; /** Map a constant type to its underlying base type, * identity for all other types */ @@ -215,8 +214,7 @@ abstract class Types: SymbolTable { * - Or phase.erasedTypes is false and both types are neither method nor * poly types. */ - def matches(that: Type): boolean = - matchesType(this, that); + def matches(that: Type): boolean = matchesType(this, that); /** The shortest sorted upwards closed array of types that contains * this type as first element. @@ -313,12 +311,13 @@ abstract class Types: SymbolTable { else baseClasses.head.newOverloaded(this, alts) } - //todo: use narrow.memberType? + //todo: use narrow only for modules? (correct? efficiency gain?) def findMember(name: Name, excludedFlags: int, requiredFlags: int): Symbol = { //System.out.println("find member " + name.decode + " in " + this + ":" + this.baseClasses);//DEBUG var members: Scope = null; var member: Symbol = NoSymbol; var excluded = excludedFlags | DEFERRED; + var self: Type = null; var continue = true; var savedCheckMalformedSwitch = checkMalformedSwitch; checkMalformedSwitch = false; @@ -341,7 +340,9 @@ abstract class Types: SymbolTable { member = sym } else if (members == null) { if (member.name != sym.name || - member != sym && !memberType(member).matches(memberType(sym))) + member != sym && { + if (self == null) self = this.narrow; + !self.memberType(member).matches(self.memberType(sym))}) members = new Scope(List(member, sym)); } else { var prevEntry = members lookupEntry sym.name; @@ -349,8 +350,9 @@ abstract class Types: SymbolTable { !(prevEntry.sym == sym || !prevEntry.sym.hasFlag(PRIVATE) && - !entry.sym.hasFlag(PRIVATE) && - (memberType(prevEntry.sym) matches memberType(sym)))) + !entry.sym.hasFlag(PRIVATE) && { + if (self == null) self = this.narrow; + (self.memberType(prevEntry.sym) matches self.memberType(sym))})) prevEntry = members lookupNextEntry prevEntry; if (prevEntry == null) { members enter sym; @@ -628,10 +630,9 @@ abstract class Types: SymbolTable { override def parents: List[Type] = sym.info.parents map transform; - override def typeOfThis = { - class bar { val res = transform(sym.typeOfThis) } - (new bar).res - } + override def typeOfThis = transform(sym.typeOfThis); + + override def narrow = if (sym.isModuleClass) transform(sym.thisType) else super.narrow; override def prefix: Type = pre; diff --git a/sources/scala/tools/nsc/typechecker/RefChecks.scala b/sources/scala/tools/nsc/typechecker/RefChecks.scala index 50798d65a2..7260ed625d 100755 --- a/sources/scala/tools/nsc/typechecker/RefChecks.scala +++ b/sources/scala/tools/nsc/typechecker/RefChecks.scala @@ -149,7 +149,8 @@ abstract class RefChecks extends Transform { for (val bc <- clazz.info.baseClasses.tail; val other <- bc.info.decls.toList) if (!other.isClass && !(other hasFlag PRIVATE) && !other.isConstructor) { val member = clazz.tpe.member(other.name) filter - (sym => sym.isType || (self.memberType(sym) matches self.memberType(other))); + (sym => sym.owner != other.owner && + (sym.isType || (self.memberType(sym) matches self.memberType(other)))); if (member hasFlag OVERLOADED) { val alt1 = member.alternatives.head; val alt2 = member.alternatives.tail.head; @@ -160,7 +161,7 @@ abstract class RefChecks extends Transform { "ambiguous override: both " + infoString(alt1) + "\n and " + infoString(alt2) + "\n override " + infoString(other)); - } else if (member != other && !(member hasFlag LOCAL)) { + } else if (member != NoSymbol && !(member hasFlag LOCAL)) { member.flags = member.flags | ACCESSED; checkOverride(clazz, member, other); } |