diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2012-11-16 14:35:48 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2012-11-16 14:35:48 -0800 |
commit | 3068ddeadc8a07f9173ba204e415b37945452037 (patch) | |
tree | 5bcec15fd17c503f462f9c218df858effa479f53 /src/reflect | |
parent | 4444369ddf39176dcfae4bcf1901697a6ccdfd42 (diff) | |
parent | 085b6a5bbed3839238c5cc0434281cf8e4c1ad19 (diff) | |
download | scala-3068ddeadc8a07f9173ba204e415b37945452037.tar.gz scala-3068ddeadc8a07f9173ba204e415b37945452037.tar.bz2 scala-3068ddeadc8a07f9173ba204e415b37945452037.zip |
Merge pull request #1622 from adriaanm/paulp-issue/5330-2
SI-5330, SI-6014 deal with existential self-type
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 3104c1e74e..02cdac4046 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -321,6 +321,18 @@ trait Types extends api.Types { self: SymbolTable => } } + /** Same as a call to narrow unless existentials are visible + * after widening the type. In that case, narrow from the widened + * type instead of the proxy. This gives buried existentials a + * chance to make peace with the other types. See SI-5330. + */ + private def narrowForFindMember(tp: Type): Type = { + val w = tp.widen + // Only narrow on widened type when we have to -- narrow is expensive unless the target is a singleton type. + if ((tp ne w) && containsExistential(w)) w.narrow + else tp.narrow + } + /** The base class for all types */ abstract class Type extends TypeApiImpl with Annotatable[Type] { /** Types for which asSeenFrom always is the identity, no matter what @@ -1070,7 +1082,7 @@ trait Types extends api.Types { self: SymbolTable => (other ne sym) && ((other.owner eq sym.owner) || (flags & PRIVATE) != 0 || { - if (self eq null) self = this.narrow + if (self eq null) self = narrowForFindMember(this) if (symtpe eq null) symtpe = self.memberType(sym) !(self.memberType(other) matches symtpe) })}) { @@ -1148,7 +1160,7 @@ trait Types extends api.Types { self: SymbolTable => if ((member ne sym) && ((member.owner eq sym.owner) || (flags & PRIVATE) != 0 || { - if (self eq null) self = this.narrow + if (self eq null) self = narrowForFindMember(this) if (membertpe eq null) membertpe = self.memberType(member) !(membertpe matches self.memberType(sym)) })) { @@ -1163,7 +1175,7 @@ trait Types extends api.Types { self: SymbolTable => (other ne sym) && ((other.owner eq sym.owner) || (flags & PRIVATE) != 0 || { - if (self eq null) self = this.narrow + if (self eq null) self = narrowForFindMember(this) if (symtpe eq null) symtpe = self.memberType(sym) !(self.memberType(other) matches symtpe) })}) { |