diff options
author | Paul Phillips <paulp@improving.org> | 2011-06-24 13:16:30 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-06-24 13:16:30 +0000 |
commit | d8a40e730fe8c5a9eb86f42850f8731e05b0e039 (patch) | |
tree | cb853d5feef083f6f74709d20a2db5bf1a1f4fa5 | |
parent | cb9c2f8335c291206b31a990e5983438523eae09 (diff) | |
download | scala-d8a40e730fe8c5a9eb86f42850f8731e05b0e039.tar.gz scala-d8a40e730fe8c5a9eb86f42850f8731e05b0e039.tar.bz2 scala-d8a40e730fe8c5a9eb86f42850f8731e05b0e039.zip |
Integrating feedback from adriaan, changed anot...
Integrating feedback from adriaan, changed another call to tpe to tpeHK
and simplified the surrounding method. No review.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index dd92418af7..4e3650bc54 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2780,39 +2780,42 @@ trait Typers extends Modes { def isRawParameter(sym: Symbol) = // is it a type parameter leaked by a raw type? sym.isTypeParameter && sym.owner.isJavaDefined - /** Given a set `rawSyms` of term- and type-symbols, and a type `tp`. - * produce a set of fresh type parameters and a type so that it can be - * abstracted to an existential type. - * Every type symbol `T` in `rawSyms` is mapped to a clone. - * Every term symbol `x` of type `T` in `rawSyms` is given an - * associated type symbol of the following form: + /** Given a set `rawSyms` of term- and type-symbols, and a type + * `tp`, produce a set of fresh type parameters and a type so that + * it can be abstracted to an existential type. Every type symbol + * `T` in `rawSyms` is mapped to a clone. Every term symbol `x` of + * type `T` in `rawSyms` is given an associated type symbol of the + * following form: * - * type x.type <: T with <singleton> + * type x.type <: T with Singleton * - * The name of the type parameter is `x.type`, to produce nice diagnostics. - * The <singleton> parent ensures that the type parameter is still seen as a stable type. - * Type symbols in rawSyms are fully replaced by the new symbols. - * Term symbols are also replaced, except when they are the term - * symbol of an Ident tree, in which case only the type of the - * Ident is changed. + * The name of the type parameter is `x.type`, to produce nice + * diagnostics. The Singleton parent ensures that the type + * parameter is still seen as a stable type. Type symbols in + * rawSyms are fully replaced by the new symbols. Term symbols are + * also replaced, except for term symbols of an Ident tree, where + * only the type of the Ident is changed. */ protected def existentialTransform(rawSyms: List[Symbol], tp: Type) = { val typeParams: List[Symbol] = rawSyms map { sym => val name = sym.name match { case x: TypeName => x - case x => newTypeName(x+".type") + case x => newTypeName(x + ".type") } - val bound = sym.existentialBound - val sowner = if (isRawParameter(sym)) context.owner else sym.owner - val quantified: Symbol = sowner.newAbstractType(sym.pos, name).setFlag(EXISTENTIAL) + val bound = sym.existentialBound + val sowner = if (isRawParameter(sym)) context.owner else sym.owner + val quantified = sowner.newExistential(sym.pos, name) - quantified.setInfo(bound.cloneInfo(quantified)) - quantified + quantified setInfo bound.cloneInfo(quantified) } - val typeParamTypes = typeParams map (_.tpe) - //println("ex trans "+rawSyms+" . "+tp+" "+typeParamTypes+" "+(typeParams map (_.info)))//DEBUG - for (tparam <- typeParams) tparam.setInfo(tparam.info.subst(rawSyms, typeParamTypes)) - (typeParams, tp.subst(rawSyms, typeParamTypes)) + // Higher-kinded existentials are not yet supported, but this is + // tpeHK for when they are: "if a type constructor is expected/allowed, + // tpeHK must be called instead of tpe." + val typeParamTypes = typeParams map (_.tpeHK) + ( + typeParams map (tparam => tparam setInfo tparam.info.subst(rawSyms, typeParamTypes)), + tp.subst(rawSyms, typeParamTypes) + ) } /** Compute an existential type from raw hidden symbols `syms` and type `tp` |