diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2012-11-16 14:34:49 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2012-11-16 14:34:49 -0800 |
commit | 2d62ab248d07f10fd89a68b12565259ca861e1e9 (patch) | |
tree | 0b51bcd44796ff8f40f9ca35a5208ffd9fee4089 /src | |
parent | 73d9ae5aa9c6866fe6794459eab9a6cd0dc5cdcd (diff) | |
parent | 65778d760fd7b80b8f0fb9e3cfe87cc87e3523ae (diff) | |
download | scala-2d62ab248d07f10fd89a68b12565259ca861e1e9.tar.gz scala-2d62ab248d07f10fd89a68b12565259ca861e1e9.tar.bz2 scala-2d62ab248d07f10fd89a68b12565259ca861e1e9.zip |
Merge pull request #1624 from adriaanm/paulp-issue/5330-2.10.x
SI-5330, SI-6014 deal with existential self-type
Diffstat (limited to 'src')
-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 de6c6285ca..6df6ed4417 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -325,6 +325,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 @@ -1079,7 +1091,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) })}) { @@ -1161,7 +1173,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)) })) { @@ -1176,7 +1188,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) })}) { |