summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-06-03 17:40:15 -0700
committerPaul Phillips <paulp@improving.org>2013-06-03 17:40:15 -0700
commit2d684df991f5c94f1fe792f8f02da2164a24c649 (patch)
tree420d0fdaa0e57be468db6bef2b06e2dd53ea9a32 /src/reflect
parent69887ddd682057c4787e2e4377830390faf8ecf1 (diff)
parent14534c693d2eb6acafaf8244c14b5643388fbd67 (diff)
downloadscala-2d684df991f5c94f1fe792f8f02da2164a24c649.tar.gz
scala-2d684df991f5c94f1fe792f8f02da2164a24c649.tar.bz2
scala-2d684df991f5c94f1fe792f8f02da2164a24c649.zip
Merge pull request #2615 from paulp/issue/7517
SI-7517 type constructors too eagerly normalized.
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala4
-rw-r--r--src/reflect/scala/reflect/internal/tpe/GlbLubs.scala16
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeMaps.scala15
3 files changed, 10 insertions, 25 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 00a929003e..dfb8632968 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -3222,7 +3222,7 @@ trait Types
if (constr.instValid) constr.inst
// get here when checking higher-order subtyping of the typevar by itself
// TODO: check whether this ever happens?
- else if (isHigherKinded) logResult("Normalizing HK $this")(typeFun(params, applyArgs(params map (_.typeConstructor))))
+ else if (isHigherKinded) logResult(s"Normalizing HK $this")(typeFun(params, applyArgs(params map (_.typeConstructor))))
else super.normalize
)
override def typeSymbol = origin.typeSymbol
@@ -3649,7 +3649,7 @@ trait Types
def existentialAbstraction(tparams: List[Symbol], tpe0: Type): Type =
if (tparams.isEmpty) tpe0
else {
- val tpe = normalizeAliases(tpe0)
+ val tpe = tpe0 map (_.dealias)
val tpe1 = new ExistentialExtrapolation(tparams) extrapolate tpe
var tparams0 = tparams
var tparams1 = tparams0 filter tpe1.contains
diff --git a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala
index 0a7a2a127c..7a10401a45 100644
--- a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala
+++ b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala
@@ -80,11 +80,11 @@ private[internal] trait GlbLubs {
var lubListDepth = 0
// This catches some recursive situations which would otherwise
// befuddle us, e.g. pos/hklub0.scala
- def isHotForTs(xs: List[Type]) = ts exists (_.typeParams == xs.map(_.typeSymbol))
+ def isHotForTs(xs: List[Type]) = ts exists (_.typeParams == xs.map(_.typeSymbolDirect))
def elimHigherOrderTypeParam(tp: Type) = tp match {
case TypeRef(_, _, args) if args.nonEmpty && isHotForTs(args) =>
- logResult("Retracting dummies from " + tp + " in lublist")(tp.typeConstructor)
+ logResult(s"Retracting dummies from $tp in lublist")(tp.typeConstructor)
case _ => tp
}
// pretypes is a tail-recursion-preserving accumulator.
@@ -101,7 +101,7 @@ private[internal] trait GlbLubs {
// Is the frontier made up of types with the same symbol?
val isUniformFrontier = (ts0: @unchecked) match {
- case t :: ts => ts forall (_.typeSymbol == t.typeSymbol)
+ case t :: ts => ts forall (_.typeSymbolDirect == t.typeSymbolDirect)
}
// Produce a single type for this frontier by merging the prefixes and arguments of those
@@ -112,11 +112,11 @@ private[internal] trait GlbLubs {
if (isUniformFrontier) {
val fbounds = findRecursiveBounds(ts0) map (_._2)
val tcLubList = typeConstructorLubList(ts0)
- def isRecursive(tp: Type) = tp.typeSymbol.typeParams exists fbounds.contains
+ def isRecursive(tp: Type) = tp.typeSymbolDirect.typeParams exists fbounds.contains
val ts1 = ts0 map { t =>
if (isRecursive(t)) {
- tcLubList map (t baseType _.typeSymbol) find (t => !isRecursive(t)) match {
+ tcLubList map (t baseType _.typeSymbolDirect) find (t => !isRecursive(t)) match {
case Some(tp) => logResult(s"Breaking recursion in lublist, substituting weaker type.\n Was: $t\n Now")(tp)
case _ => t
}
@@ -133,7 +133,7 @@ private[internal] trait GlbLubs {
// frontier is not uniform yet, move it beyond the current minimal symbol;
// lather, rinSe, repeat
val sym = minSym(ts0)
- val newtps = tsBts map (ts => if (ts.head.typeSymbol == sym) ts.tail else ts)
+ val newtps = tsBts map (ts => if (ts.head.typeSymbolDirect == sym) ts.tail else ts)
if (printLubs) {
val str = (newtps.zipWithIndex map { case (tps, idx) =>
tps.map(" " + _ + "\n").mkString(" (" + idx + ")\n", "", "\n")
@@ -157,9 +157,7 @@ private[internal] trait GlbLubs {
/** The minimal symbol of a list of types (as determined by `Symbol.isLess`). */
private def minSym(tps: List[Type]): Symbol =
- (tps.head.typeSymbol /: tps.tail) {
- (sym1, tp2) => if (tp2.typeSymbol isLess sym1) tp2.typeSymbol else sym1
- }
+ tps.iterator map (_.typeSymbolDirect) reduceLeft ((x, y) => if (x isLess y) x else y)
/** A minimal type list which has a given list of types as its base type sequence */
def spanningTypes(ts: List[Type]): List[Type] = ts match {
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
index c35825dcee..76d02f5f9d 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
@@ -12,19 +12,6 @@ private[internal] trait TypeMaps {
self: SymbolTable =>
import definitions._
- /** Normalize any type aliases within this type (@see Type#normalize).
- * Note that this depends very much on the call to "normalize", not "dealias",
- * so it is no longer carries the too-stealthy name "deAlias".
- */
- object normalizeAliases extends TypeMap {
- def apply(tp: Type): Type = tp match {
- case TypeRef(_, sym, _) if sym.isAliasType =>
- def msg = if (tp.isHigherKinded) s"Normalizing type alias function $tp" else s"Dealiasing type alias $tp"
- mapOver(logResult(msg)(tp.normalize))
- case _ => mapOver(tp)
- }
- }
-
/** Remove any occurrence of type <singleton> from this type and its parents */
object dropSingletonType extends TypeMap {
def apply(tp: Type): Type = {
@@ -389,7 +376,7 @@ private[internal] trait TypeMaps {
case TypeRef(pre, sym, args) if tparams contains sym =>
val repl = if (variance.isPositive) dropSingletonType(tp1.bounds.hi) else tp1.bounds.lo
val count = occurCount(sym)
- val containsTypeParam = tparams exists (repl contains _)
+ val containsTypeParam = tparams exists repl.contains
def msg = {
val word = if (variance.isPositive) "upper" else "lower"
s"Widened lone occurrence of $tp1 inside existential to $word bound"