summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-11-19 06:59:19 +0000
committerPaul Phillips <paulp@improving.org>2011-11-19 06:59:19 +0000
commit334872e33be8385678697f3d670c8102d38cdca7 (patch)
treed89531734d6c57e0dcd2eb7bd934e8beae888633 /src/compiler/scala/tools/nsc/typechecker/Implicits.scala
parent7eb6f102e8e3bf90319e0339938d7e6eb5aaea43 (diff)
downloadscala-334872e33be8385678697f3d670c8102d38cdca7.tar.gz
scala-334872e33be8385678697f3d670c8102d38cdca7.tar.bz2
scala-334872e33be8385678697f3d670c8102d38cdca7.zip
Bringing a bit of order to symbol substitution.
Painstakingly winnowed out the most frequently duplicated code sequences related to symbol cloning and substitution. Created canonical methods to perform these actions and documented them. Key methods include: def createFromClonedSymbols[T](syms: List[Symbol], tpe: Type)(creator: (List[Symbol], Type) => T): T def deriveSymbols(syms: List[Symbol], symFn: Symbol => Symbol): List[Symbol] def deriveType(syms: List[Symbol], symFn: Symbol => Symbol)(tpe: Type): Type Many example usages enclosed with commit. I did lots of timing tests, I find no material difference before and after. Actually I won by four seconds in this incarnation: Before - Total time: 7 minutes 55 seconds After - Total time: 7 minutes 51 seconds Review by moors.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 2c32d22081..b67198a292 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -297,8 +297,7 @@ trait Implicits {
case _ => tp
}
def stripped(tp: Type): Type = {
- val tparams = freeTypeParametersNoSkolems.collect(tp)
- tp.subst(tparams, tparams map (t => WildcardType))
+ deriveTypeWithWildcards(freeTypeParametersNoSkolems.collect(tp))(tp)
}
def sum(xs: List[Int]) = (0 /: xs)(_ + _)
def complexity(tp: Type): Int = tp.normalize match {
@@ -371,11 +370,7 @@ trait Implicits {
/** The type parameters to instantiate */
val undetParams = if (isView) List() else context.outer.undetparams
-
- def approximate(tp: Type) =
- if (undetParams.isEmpty) tp
- else tp.instantiateTypeParams(undetParams, undetParams map (_ => WildcardType))
-
+ def approximate(tp: Type) = deriveTypeWithWildcards(undetParams)(tp)
val wildPt = approximate(pt)
/** Try to construct a typed tree from given implicit info with given