From d8ffaac6ae544457fa43f2ede674bbe80930cc27 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 19 Nov 2013 20:23:40 +0100 Subject: Code reformatting in Implicits And use List#sum, rather than a fold. No functional change. --- .../scala/tools/nsc/typechecker/Implicits.scala | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index c3891dc707..d9a4f60d48 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -388,11 +388,11 @@ trait Implicits { */ private def dominates(dtor: Type, dted: Type): Boolean = { def core(tp: Type): Type = tp.dealiasWiden match { - case RefinedType(parents, defs) => intersectionType(parents map core, tp.typeSymbol.owner) + case RefinedType(parents, defs) => intersectionType(parents map core, tp.typeSymbol.owner) case AnnotatedType(annots, tp, selfsym) => core(tp) - case ExistentialType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi))) - case PolyType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi))) - case _ => tp + case ExistentialType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi))) + case PolyType(tparams, result) => core(result).subst(tparams, tparams map (t => core(t.info.bounds.hi))) + case _ => tp } def stripped(tp: Type): Type = { // `t.typeSymbol` returns the symbol of the normalized type. If that normalized type @@ -401,23 +401,17 @@ trait Implicits { val syms = for (t <- tp; if t.typeSymbol.isTypeParameter) yield t.typeSymbol deriveTypeWithWildcards(syms.distinct)(tp) } - def sum(xs: List[Int]) = (0 /: xs)(_ + _) def complexity(tp: Type): Int = tp.dealias match { - case NoPrefix => - 0 - case SingleType(pre, sym) => - if (sym.isPackage) 0 else complexity(tp.dealiasWiden) - case TypeRef(pre, sym, args) => - complexity(pre) + sum(args map complexity) + 1 - case RefinedType(parents, _) => - sum(parents map complexity) + 1 - case _ => - 1 + case NoPrefix => 0 + case SingleType(pre, sym) => if (sym.isPackage) 0 else complexity(tp.dealiasWiden) + case TypeRef(pre, sym, args) => complexity(pre) + (args map complexity).sum + 1 + case RefinedType(parents, _) => (parents map complexity).sum + 1 + case _ => 1 } def overlaps(tp1: Type, tp2: Type): Boolean = (tp1, tp2) match { case (RefinedType(parents, _), _) => parents exists (overlaps(_, tp2)) case (_, RefinedType(parents, _)) => parents exists (overlaps(tp1, _)) - case _ => tp1.typeSymbol == tp2.typeSymbol + case _ => tp1.typeSymbol == tp2.typeSymbol } val dtor1 = stripped(core(dtor)) val dted1 = stripped(core(dted)) -- cgit v1.2.3