From 09f7ab1554b1207beb1a7c604e103a1178b6a263 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 27 Jun 2016 10:43:28 +0200 Subject: Handle findMember for unreduced hk types. - Follow upper bound, as before. - But if type constructor is a lambda, needs special treatment. --- src/dotty/tools/dotc/core/Types.scala | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 38a7c14b1..f41dca433 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -462,6 +462,8 @@ object Types { goParam(tp) case tp: RecType => goRec(tp) + case tp: HKApply => + goApply(tp) case tp: TypeProxy => go(tp.underlying) case tp: ClassInfo => @@ -548,6 +550,16 @@ object Types { } } + def goApply(tp: HKApply) = tp.tycon match { + case tl: TypeLambda => + val res = + go(tl.resType).mapInfo(info => + tl.derivedTypeLambda(tl.paramNames, tl.paramBounds, info).appliedTo(tp.args)) + //println(i"remapping $tp . $name to ${res.info}")// " / ${res.toString}") + res + case _ => go(tp.underlying) + } + def goThis(tp: ThisType) = { val d = go(tp.underlying) if (d.exists) @@ -2674,14 +2686,21 @@ object Types { class TypeLambda(paramNames: List[TypeName], override val variances: List[Int])(paramBoundsExp: GenericType => List[TypeBounds], resultTypeExp: GenericType => Type) extends GenericType(paramNames)(paramBoundsExp, resultTypeExp) with ValueType { - assert(resType.isValueType, this) + assert(resType.isInstanceOf[TermType], this) assert(paramNames.nonEmpty) lazy val typeParams: List[LambdaParam] = paramNames.indices.toList.map(new LambdaParam(this, _)) - def derivedTypeLambda(paramNames: List[TypeName], paramBounds: List[TypeBounds], resType: Type)(implicit ctx: Context) = - derivedGenericType(paramNames, paramBounds, resType) + def derivedTypeLambda(paramNames: List[TypeName], paramBounds: List[TypeBounds], resType: Type)(implicit ctx: Context): Type = + resType match { + case resType @ TypeAlias(alias) => + resType.derivedTypeAlias(duplicate(paramNames, paramBounds, alias)) + case resType @ TypeBounds(lo, hi) => + resType.derivedTypeBounds(lo, duplicate(paramNames, paramBounds, hi)) + case _ => + derivedGenericType(paramNames, paramBounds, resType) + } def duplicate(paramNames: List[TypeName] = this.paramNames, paramBounds: List[TypeBounds] = this.paramBounds, resType: Type)(implicit ctx: Context): TypeLambda = TypeLambda(paramNames, variances)( -- cgit v1.2.3