aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/transform
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-02-14 16:53:41 +0100
committerMartin Odersky <odersky@gmail.com>2017-02-14 16:53:41 +0100
commitb89738672662863168453a1bd6c6c47a6ff07f11 (patch)
tree3799954fb6ac7aa581786031834f440172a4e166 /compiler/src/dotty/tools/dotc/transform
parent17469b82ca7afc5376bc3906bb5b64d10f38a100 (diff)
downloaddotty-b89738672662863168453a1bd6c6c47a6ff07f11.tar.gz
dotty-b89738672662863168453a1bd6c6c47a6ff07f11.tar.bz2
dotty-b89738672662863168453a1bd6c6c47a6ff07f11.zip
Avoid automatism for passing variances to PolyTypes
We used to "fill-in" with zeroes if variances were missing. I now think that;'s too error-prone. Better define all variances explicitly.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform')
-rw-r--r--compiler/src/dotty/tools/dotc/transform/FullParameterization.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala
index 6c69c735b..9e43fc999 100644
--- a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala
+++ b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala
@@ -101,6 +101,7 @@ trait FullParameterization {
}
val ctparams = if (abstractOverClass) clazz.typeParams else Nil
val ctnames = ctparams.map(_.name.unexpandedName)
+ val ctvariances = ctparams.map(_.variance)
/** The method result type */
def resultType(mapClassParams: Type => Type) = {
@@ -122,14 +123,14 @@ trait FullParameterization {
info match {
case info: PolyType =>
- PolyType(info.paramNames ++ ctnames)(
+ PolyType(info.paramNames ++ ctnames, info.variances ++ ctvariances)(
pt =>
(info.paramBounds.map(mapClassParams(_, pt).bounds) ++
mappedClassBounds(pt)).mapConserve(_.subst(info, pt).bounds),
pt => resultType(mapClassParams(_, pt)).subst(info, pt))
case _ =>
if (ctparams.isEmpty) resultType(identity)
- else PolyType(ctnames)(mappedClassBounds, pt => resultType(mapClassParams(_, pt)))
+ else PolyType(ctnames, ctvariances)(mappedClassBounds, pt => resultType(mapClassParams(_, pt)))
}
}