aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeOps.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-12 18:07:36 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-12 18:07:36 +0100
commit80acc2d331cf8359c00d9a15c8cc10d537be503a (patch)
tree52665a28aed3fd663dccd26d2c8f89b89b5f5479 /src/dotty/tools/dotc/core/TypeOps.scala
parenta6c50c1872cff7ffb20388c7ac2197d983085625 (diff)
downloaddotty-80acc2d331cf8359c00d9a15c8cc10d537be503a.tar.gz
dotty-80acc2d331cf8359c00d9a15c8cc10d537be503a.tar.bz2
dotty-80acc2d331cf8359c00d9a15c8cc10d537be503a.zip
Some changes in the interest of speedups.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 1a782ac63..6e984e43c 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -47,6 +47,28 @@ trait TypeOps { this: Context =>
def apply(tp: Type) = asSeenFrom(tp, pre, cls, this)
}
+ /** Implementation of Types#simplified */
+ final def simplify(tp: Type, theMap: SimplifyMap): Type = tp match {
+ case tp: NamedType =>
+ tp.derivedSelect(simplify(tp.prefix, theMap))
+ case _: ThisType | NoPrefix =>
+ tp
+ case tp: RefinedType =>
+ tp.derivedRefinedType(simplify(tp.parent, theMap), tp.refinedName, simplify(tp.refinedInfo, theMap))
+ case AndType(l, r) =>
+ simplify(l, theMap) & simplify(r, theMap)
+ case OrType(l, r) =>
+ simplify(l, theMap) | simplify(r, theMap)
+ case tp: PolyParam =>
+ typerState.constraint.typeVarOfParam(tp) orElse tp
+ case _ =>
+ (if (theMap != null) theMap else new SimplifyMap).mapOver(tp)
+ }
+
+ class SimplifyMap extends TypeMap {
+ def apply(tp: Type) = simplify(tp, this)
+ }
+
final def isVolatile(tp: Type): Boolean = {
/** Pre-filter to avoid expensive DNF computation */
def needsChecking(tp: Type, isPart: Boolean): Boolean = tp match {