diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-18 18:46:24 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-06 13:15:28 +0200 |
commit | f6c61f3976a2780ce42ea6cd814986b662570687 (patch) | |
tree | 55ba214a169584e8ea2d7faff5c34296951b9b3b /compiler/src/dotty/tools/dotc/core | |
parent | 8b1340b9b73d319ef7ac8f7f3bdaa75943de277e (diff) | |
download | dotty-f6c61f3976a2780ce42ea6cd814986b662570687.tar.gz dotty-f6c61f3976a2780ce42ea6cd814986b662570687.tar.bz2 dotty-f6c61f3976a2780ce42ea6cd814986b662570687.zip |
Split HKTypeLambda from PolyType
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core')
4 files changed, 8 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index eb3394082..1882489a5 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -75,7 +75,7 @@ object TypeApplications { } def unapply(tp: Type)(implicit ctx: Context): Option[TypeRef] = tp match { - case tp @ PolyType/*###*/(tparams, AppliedType(fn: TypeRef, args)) if (args == tparams.map(_.toArg)) => Some(fn) + case tp @ HKTypeLambda(tparams, AppliedType(fn: TypeRef, args)) if (args == tparams.map(_.toArg)) => Some(fn) case _ => None } } @@ -253,7 +253,7 @@ class TypeApplications(val self: Type) extends AnyVal { def isHK(implicit ctx: Context): Boolean = self.dealias match { case self: TypeRef => self.info.isHK case self: RefinedType => false - case self: TypeLambda => true + case self: HKTypeLambda => true case self: SingletonType => false case self: TypeVar => // Using `origin` instead of `underlying`, as is done for typeParams, @@ -339,10 +339,10 @@ class TypeApplications(val self: Type) extends AnyVal { if (hkParams.isEmpty) self else { def adaptArg(arg: Type): Type = arg match { - case arg @ PolyType(tparams, body) if /*###*/ + case arg @ HKTypeLambda(tparams, body) if !tparams.corresponds(hkParams)(_.paramVariance == _.paramVariance) && tparams.corresponds(hkParams)(varianceConforms) => - PolyType(/*###*/ + HKTypeLambda( (tparams, hkParams).zipped.map((tparam, hkparam) => tparam.paramName.withVariance(hkparam.paramVariance)))( tl => arg.paramInfos.map(_.subst(arg, tl).bounds), diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 597b28088..131c31d6b 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -669,7 +669,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { val tparams1 = tparams1a.drop(lengthDiff) variancesConform(tparams1, tparams) && { if (lengthDiff > 0) - tycon1b = PolyType(tparams1.map(_.paramName))(/*###*/ + tycon1b = HKTypeLambda(tparams1.map(_.paramName))( tl => tparams1.map(tparam => tl.integrate(tparams, tparam.paramInfo).bounds), tl => tycon1a.appliedTo(args1.take(lengthDiff) ++ tparams1.indices.toList.map(TypeParamRef(tl, _)))) @@ -1280,7 +1280,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { else if (tparams2.isEmpty) original(tp1.appliedTo(tp1.typeParams.map(_.paramInfoAsSeenFrom(tp1))), tp2) else - PolyType(/*###*/ + HKTypeLambda( paramNames = (tpnme.syntheticTypeParamNames(tparams1.length), tparams1, tparams2) .zipped.map((pname, tparam1, tparam2) => pname.withVariance((tparam1.paramVariance + tparam2.paramVariance) / 2)))( diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 4ba0a2924..d0c7990f8 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -2762,7 +2762,7 @@ object Types { * type T[X] >: L <: U becomes type T >: ([X] -> L) <: ([X] -> U) */ override def fromParams[PI <: ParamInfo.Of[TypeName]](params: List[PI], resultType: Type)(implicit ctx: Context): Type = { - def expand(tp: Type) = PolyType.fromParams(params, tp) //### + def expand(tp: Type) = super.fromParams(params, tp) resultType match { case rt: TypeAlias => rt.derivedTypeAlias(expand(rt.alias)) @@ -2788,9 +2788,6 @@ object Types { def any(n: Int)(implicit ctx: Context) = apply(syntheticParamNames(n))( pt => List.fill(n)(TypeBounds.empty), pt => defn.AnyType) - - override def paramName(param: ParamInfo.Of[TypeName])(implicit ctx: Context): TypeName = - param.paramName.withVariance(param.paramVariance) //### } private object DepStatus { diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index fc9d9c447..902d01c21 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -255,7 +255,7 @@ class TreePickler(pickler: TastyPickler) { pickleType(tpe.underlying) case tpe: HKTypeLambda => pickleMethodic(TYPELAMBDAtype, tpe) - case tpe: PolyType /*if richTypes*/ => //### + case tpe: PolyType if richTypes => pickleMethodic(POLYtype, tpe) case tpe: MethodType if richTypes => pickleMethodic(METHODtype, tpe) |