aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-12-06 09:24:43 +0100
committerMartin Odersky <odersky@gmail.com>2015-12-06 16:17:44 +0100
commit50d265299ab99ace68e3813794559de2bbcdc91c (patch)
treecdee93babc11a3ee551ce00890bf6c4bcff4e217 /src/dotty/tools/dotc
parent651930949e370b21e46bedba0f58fc92e37a33f6 (diff)
downloaddotty-50d265299ab99ace68e3813794559de2bbcdc91c.tar.gz
dotty-50d265299ab99ace68e3813794559de2bbcdc91c.tar.bz2
dotty-50d265299ab99ace68e3813794559de2bbcdc91c.zip
Be DRY betweeen EtaExpand and LambdaAbstract
All Lambda abstractions, not just eta expansions, should use actual parameter bounds, not the one retrieved from the parameter symbols.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index b86c58030..db7550402 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -92,12 +92,7 @@ object TypeApplications {
object EtaExpansion {
def apply(tycon: TypeRef)(implicit ctx: Context) = {
assert(tycon.isEtaExpandable)
- val tparams = tycon.typeParams
- val variances = tycon.typeParams.map(_.variance)
- TypeLambda(
- tparams.map(_.variance),
- tycon.paramBounds.map(internalize(_, tycon.typeParams)),
- rt => tycon.appliedTo(argRefs(rt, tparams.length)))
+ tycon.EtaExpand(tycon.typeParams)
}
def unapply(tp: Type)(implicit ctx: Context): Option[TypeRef] = {
@@ -164,10 +159,6 @@ object TypeApplications {
}
}
- 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] =
@@ -235,9 +226,6 @@ class TypeApplications(val self: Type) extends AnyVal {
final def hkTypeParams(implicit ctx: Context): List[TypeSymbol] =
self.LambdaTrait.typeParams
- final def paramBounds(implicit ctx: Context): List[TypeBounds] =
- typeParams.map(self.memberInfo(_).bounds)
-
/** The Lambda trait underlying a type lambda */
def LambdaTrait(implicit ctx: Context): Symbol = self.stripTypeVar match {
case RefinedType(parent, tpnme.hkApply) =>
@@ -262,11 +250,15 @@ class TypeApplications(val self: Type) extends AnyVal {
* type T[X] >: L <: U becomes type T >: L <: ([X] -> _ <: U)
*/
def LambdaAbstract(tparams: List[Symbol])(implicit ctx: Context): Type = {
+ def internalize[T <: Type](tp: T) =
+ (rt: RefinedType) =>
+ new ctx.SafeSubstMap(tparams, argRefs(rt, tparams.length))
+ .apply(tp).asInstanceOf[T]
def expand(tp: Type) = {
TypeLambda(
tparams.map(_.variance),
- tparams.map(tparam => internalize(tparam.info.bounds, tparams)),
- internalize(tp, tparams))
+ tparams.map(tparam => internalize(self.memberInfo(tparam).bounds)),
+ internalize(tp))
}
self match {
case self: TypeAlias =>