diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-22 17:49:05 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-26 18:52:33 +0100 |
commit | b8f8b558a047246e0318a08c58d99b7c63997395 (patch) | |
tree | 49410799c7ce5721d2c98a7091c820e8e643f0a3 /src/dotty/tools/dotc/core/Types.scala | |
parent | aad81eb4af4ae1202268f18bebaac7cf7d0fcc20 (diff) | |
download | dotty-b8f8b558a047246e0318a08c58d99b7c63997395.tar.gz dotty-b8f8b558a047246e0318a08c58d99b7c63997395.tar.bz2 dotty-b8f8b558a047246e0318a08c58d99b7c63997395.zip |
Refactoctored widening operations.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 0325c5460..622672515 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -537,19 +537,16 @@ object Types { * def o: Outer * <o.x.type>.widen = o.C */ - final def widen(implicit ctx: Context): Type = this match { - case tp: TermRef => - if (tp.denot.isOverloaded) tp else tp.underlying.widen - case tp: SingletonType => tp.underlying.widen + final def widen(implicit ctx: Context): Type = widenSingleton match { case tp: ExprType => tp.resultType.widen - case _ => this + case tp => tp } /** Widen from singleton type to its underlying non-singleton * base type by applying one or more `underlying` dereferences, */ final def widenSingleton(implicit ctx: Context): Type = this match { - case tp: SingletonType => tp.underlying.widenSingleton + case tp: SingletonType if !tp.isOverloaded => tp.underlying.widenSingleton case _ => this } @@ -1037,7 +1034,9 @@ object Types { /** A marker trait for types that are guaranteed to contain only a * single non-null value (they might contain null in addition). */ - trait SingletonType extends TypeProxy with ValueType + trait SingletonType extends TypeProxy with ValueType { + def isOverloaded(implicit ctx: Context) = false + } /** A marker trait for types that bind other types that refer to them. * Instances are: PolyType, MethodType, RefinedType. @@ -1189,7 +1188,7 @@ object Types { override def signature(implicit ctx: Context): Signature = denot.signature - def isOverloaded(implicit ctx: Context) = denot.isOverloaded + override def isOverloaded(implicit ctx: Context) = denot.isOverloaded private def rewrap(sd: SingleDenotation)(implicit ctx: Context) = TermRef(prefix, name, sd) |