diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-14 16:47:55 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-06 13:15:27 +0200 |
commit | 6545606cefaf8ec7090f8a601123bfae61b441a6 (patch) | |
tree | 8d8f261fb6c9807923ea60f4611b8c2b6e4f3ddf /compiler/src/dotty/tools/dotc/core/TypeApplications.scala | |
parent | 62c2a1e2d6265cf7f096e4c4e51e4e883bce1514 (diff) | |
download | dotty-6545606cefaf8ec7090f8a601123bfae61b441a6.tar.gz dotty-6545606cefaf8ec7090f8a601123bfae61b441a6.tar.bz2 dotty-6545606cefaf8ec7090f8a601123bfae61b441a6.zip |
Encode variances in parameter names
This leads to a slight overall simplification, harmonizes pickle
format with internal representation, and makes MethodTypes and
PolyTypes more similar to each other.
I believe the change is useful as it is, but in particular it is
a useful step for an eventual unification of MethodTypes and
PolyTypes.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeApplications.scala | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index ba3e6a461..a7ce1ee85 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -278,9 +278,10 @@ class TypeApplications(val self: Type) extends AnyVal { * TODO: Handle parameterized lower bounds */ def LambdaAbstract(tparams: List[TypeParamInfo])(implicit ctx: Context): Type = { + def nameWithVariance(tparam: TypeParamInfo) = + tparam.paramName.withVariance(tparam.paramVariance) def expand(tp: Type) = - PolyType( - tparams.map(_.paramName), tparams.map(_.paramVariance))( + PolyType(tparams.map(nameWithVariance))( tl => tparams.map(tparam => tl.lifted(tparams, tparam.paramBounds).bounds), tl => tl.lifted(tparams, tp)) if (tparams.isEmpty) self @@ -365,7 +366,9 @@ class TypeApplications(val self: Type) extends AnyVal { case arg @ PolyType(tparams, body) if !tparams.corresponds(hkParams)(_.paramVariance == _.paramVariance) && tparams.corresponds(hkParams)(varianceConforms) => - PolyType(tparams.map(_.paramName), hkParams.map(_.paramVariance))( + PolyType( + (tparams, hkParams).zipped.map((tparam, hkparam) => + tparam.paramName.withVariance(hkparam.paramVariance)))( tl => arg.paramBounds.map(_.subst(arg, tl).bounds), tl => arg.resultType.subst(arg, tl) ) |