summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-10-20 19:50:45 +0000
committerPaul Phillips <paulp@improving.org>2011-10-20 19:50:45 +0000
commitac7b8020ebc4ba25542314dd4521765700c29f92 (patch)
tree36d5345ed121ccfcebe423af652c705616b37d43 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent5fb68614da51c601e354d13ae123820b355594d0 (diff)
downloadscala-ac7b8020ebc4ba25542314dd4521765700c29f92.tar.gz
scala-ac7b8020ebc4ba25542314dd4521765700c29f92.tar.bz2
scala-ac7b8020ebc4ba25542314dd4521765700c29f92.zip
More decomposition of Namers.
Having I think established this isn't merely a dance around the maypole, I'm going to continue breaking down Namers because it's hard to figure out where my stubbing mechanism is colliding with the existing logic. Getting there, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index ba1a9d6bfd..3cdfca9cf4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3003,6 +3003,29 @@ trait Typers extends Modes with Adaptations {
packSymbols(localSyms.toList, normalizedTpe)
}
+ /** Replace type parameters with their TypeSkolems, which can later
+ * be deskolemized to the original type param. (A skolem is a
+ * representation of a bound variable when viewed inside its scope)
+ * !!!Adriaan: this does not work for hk types.
+ */
+ def skolemizeTypeParams(tparams: List[TypeDef]): List[TypeDef] = {
+ class Deskolemizer extends LazyType {
+ override val typeParams = tparams map (_.symbol)
+ val typeSkolems = typeParams map (_.newTypeSkolem) map (_ setInfo this)
+ def substitute() = {
+ // Replace the symbols
+ (tparams, typeSkolems).zipped foreach (_.symbol = _)
+ tparams
+ }
+ override def complete(sym: Symbol) {
+ // The info of a skolem is the skolemized info of the
+ // actual type parameter of the skolem
+ sym setInfo sym.deSkolemize.info.substSym(typeParams, typeSkolems)
+ }
+ }
+ (new Deskolemizer).substitute()
+ }
+
protected def typedExistentialTypeTree(tree: ExistentialTypeTree, mode: Int): Tree = {
for (wc <- tree.whereClauses)
if (wc.symbol == NoSymbol) { namer.enterSym(wc); wc.symbol setFlag EXISTENTIAL }