diff options
author | Martin Odersky <odersky@gmail.com> | 2015-12-05 23:52:41 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-12-06 16:17:44 +0100 |
commit | 651930949e370b21e46bedba0f58fc92e37a33f6 (patch) | |
tree | cd35fc67c61608c0d643d49e45260db8a6f050ae /src/dotty/tools/dotc/core/TypeApplications.scala | |
parent | 56dd29d3d3b0524d03a93965160e651a5d757b92 (diff) | |
download | dotty-651930949e370b21e46bedba0f58fc92e37a33f6.tar.gz dotty-651930949e370b21e46bedba0f58fc92e37a33f6.tar.bz2 dotty-651930949e370b21e46bedba0f58fc92e37a33f6.zip |
Allow for F-bounded bounds in TypeLambda
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 0f9cb8230..b86c58030 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -54,18 +54,18 @@ object TypeApplications { */ object TypeLambda { def apply(variances: List[Int], - argBoundss: List[TypeBounds], + argBoundsFns: List[RefinedType => TypeBounds], bodyFn: RefinedType => Type)(implicit ctx: Context): Type = { - def argRefinements(parent: Type, i: Int, bs: List[TypeBounds]): Type = bs match { + def argRefinements(parent: Type, i: Int, bs: List[RefinedType => TypeBounds]): Type = bs match { case b :: bs1 => argRefinements(RefinedType(parent, tpnme.hkArg(i), b), i + 1, bs1) case nil => parent } assert(variances.nonEmpty) - assert(argBoundss.length == variances.length) + assert(argBoundsFns.length == variances.length) RefinedType( - argRefinements(defn.LambdaTrait(variances).typeRef, 0, argBoundss), + argRefinements(defn.LambdaTrait(variances).typeRef, 0, argBoundsFns), tpnme.hkApply, bodyFn(_).bounds.withVariance(1)) } @@ -94,7 +94,9 @@ object TypeApplications { assert(tycon.isEtaExpandable) val tparams = tycon.typeParams val variances = tycon.typeParams.map(_.variance) - TypeLambda(tparams.map(_.variance), tycon.paramBounds, + TypeLambda( + tparams.map(_.variance), + tycon.paramBounds.map(internalize(_, tycon.typeParams)), rt => tycon.appliedTo(argRefs(rt, tparams.length))) } @@ -162,7 +164,11 @@ object TypeApplications { } } - /** Adapt all arguments to possible higher-kinded type parameters using adaptIfHK + private def internalize[T <: Type](tp: T, tparams: List[Symbol])(implicit ctx: Context) = + (rt: RefinedType) => + new ctx.SafeSubstMap(tparams, argRefs(rt, tparams.length)).apply(tp).asInstanceOf[T] + + /** Adapt all arguments to possible higher-kinded type parameters using adaptIfHK */ def adaptArgs(tparams: List[Symbol], args: List[Type])(implicit ctx: Context): List[Type] = if (tparams.isEmpty) args @@ -257,8 +263,10 @@ class TypeApplications(val self: Type) extends AnyVal { */ def LambdaAbstract(tparams: List[Symbol])(implicit ctx: Context): Type = { def expand(tp: Type) = { - TypeLambda(tparams.map(_.variance), tparams.map(_.info.bounds), - rt => new ctx.SafeSubstMap(tparams, argRefs(rt, tparams.length)).apply(tp)) + TypeLambda( + tparams.map(_.variance), + tparams.map(tparam => internalize(tparam.info.bounds, tparams)), + internalize(tp, tparams)) } self match { case self: TypeAlias => |