diff options
author | Martin Odersky <odersky@gmail.com> | 2016-06-27 10:43:28 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-11 13:35:05 +0200 |
commit | 09f7ab1554b1207beb1a7c604e103a1178b6a263 (patch) | |
tree | 8cd961ed8e520314ab1e4c90cc087c7e2c2200b2 /src/dotty/tools/dotc/core/Types.scala | |
parent | 646bf97d7c2e66b4332b86f2e6cd6440fc442215 (diff) | |
download | dotty-09f7ab1554b1207beb1a7c604e103a1178b6a263.tar.gz dotty-09f7ab1554b1207beb1a7c604e103a1178b6a263.tar.bz2 dotty-09f7ab1554b1207beb1a7c604e103a1178b6a263.zip |
Handle findMember for unreduced hk types.
- Follow upper bound, as before.
- But if type constructor is a lambda, needs
special treatment.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 25 |
1 files changed, 22 insertions, 3 deletions
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)( |