diff options
author | Martin Odersky <odersky@gmail.com> | 2015-12-11 13:48:51 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-12-11 13:49:19 +0100 |
commit | b8e05d5b955de664e4a5872f43c8184014cecf05 (patch) | |
tree | f3ccaf2021cefc2da455322d42d6d6b4d12c7e7d /src/dotty/tools/dotc | |
parent | 6cb2a3bcee8bc4fb9ae4d148c8e620d3ae41040f (diff) | |
download | dotty-b8e05d5b955de664e4a5872f43c8184014cecf05.tar.gz dotty-b8e05d5b955de664e4a5872f43c8184014cecf05.tar.bz2 dotty-b8e05d5b955de664e4a5872f43c8184014cecf05.zip |
Add isBottomType/Class tests to Definitions
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Inferencing.scala | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 650cfe79c..5f794f2d5 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -588,6 +588,12 @@ class Definitions { name.startsWith(prefix) && name.drop(prefix.length).forall(_.isDigit) } + def isBottomClass(cls: Symbol) = cls == NothingClass || cls == NullClass + def isBottomType(tp: Type) = tp match { + case tp: TypeRef => isBottomClass(tp.symbol) + case _ => false + } + def isFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.Function) def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.AbstractFunction) def isTupleClass(cls: Symbol) = isVarArityClass(cls, tpnme.Tuple) diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala index 1e8dcf4b2..9717b5625 100644 --- a/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/src/dotty/tools/dotc/typer/Inferencing.scala @@ -89,7 +89,7 @@ object Inferencing { val minimize = variance >= 0 && !( force == ForceDegree.noBottom && - isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true))) + defn.isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true))) if (minimize) instantiate(tvar, fromBelow = true) else toMaximize = true } @@ -173,9 +173,6 @@ object Inferencing { approxAbove - approxBelow } - def isBottomType(tp: Type)(implicit ctx: Context) = - tp == defn.NothingType || tp == defn.NullType - /** Recursively widen and also follow type declarations and type aliases. */ def widenForMatchSelector(tp: Type)(implicit ctx: Context): Type = tp.widen match { case tp: TypeRef if !tp.symbol.isClass => widenForMatchSelector(tp.info.bounds.hi) |