diff options
author | Martin Odersky <odersky@gmail.com> | 2017-04-10 16:35:01 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-11 18:00:59 +0200 |
commit | 053cd236ee12f877cfd71affb9a62a417f917d3d (patch) | |
tree | c6e6a1c078e64e1719896f519a3cb95ebf7326d7 /compiler/src/dotty/tools/dotc/core | |
parent | 9917029becab32d56e786ac9309ee195737f6da0 (diff) | |
download | dotty-053cd236ee12f877cfd71affb9a62a417f917d3d.tar.gz dotty-053cd236ee12f877cfd71affb9a62a417f917d3d.tar.bz2 dotty-053cd236ee12f877cfd71affb9a62a417f917d3d.zip |
Fix #2152: Instantiate dependent result type parameters
#2152 shows that dependent result type parameters can end up in
the types of terms, so we have to eliminate them. If we don't we
get orphan parameters in pickling.
Fix method name and comment
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/NameKinds.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeOps.scala | 4 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Types.scala | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/NameKinds.scala b/compiler/src/dotty/tools/dotc/core/NameKinds.scala index 0f08e4701..81ac3a02f 100644 --- a/compiler/src/dotty/tools/dotc/core/NameKinds.scala +++ b/compiler/src/dotty/tools/dotc/core/NameKinds.scala @@ -209,7 +209,7 @@ object NameKinds { val InlineAccessorName = new UniqueNameKind("$_inlineAccessor_$") val TempResultName = new UniqueNameKind("ev$") val EvidenceParamName = new UniqueNameKind("evidence$") - val DepParamName = new UniqueNameKind("<param>") + val DepParamName = new UniqueNameKind("(param)") val LazyImplicitName = new UniqueNameKind("$_lazy_implicit_$") val LazyLocalName = new UniqueNameKind("$lzy") val LazyLocalInitName = new UniqueNameKind("$lzyINIT") diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index 9593bfe93..0de823e97 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -7,6 +7,7 @@ import SymDenotations._, Denotations.SingleDenotation import config.Printers.typr import util.Positions._ import NameOps._ +import NameKinds.DepParamName import Decorators._ import StdNames._ import Annotations._ @@ -169,6 +170,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object. simplify(l, theMap) & simplify(r, theMap) case OrType(l, r) => simplify(l, theMap) | simplify(r, theMap) + case tp: TypeVar if tp.origin.paramName.is(DepParamName) => + val effectiveVariance = if (theMap == null) 1 else theMap.variance + tp.instanceOpt orElse tp.instantiate(fromBelow = effectiveVariance != -1) case _ => (if (theMap != null) theMap else new SimplifyMap).mapOver(tp) } diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index c8c1886cc..955a5a11c 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3509,7 +3509,7 @@ object Types { def apply(tp: Type): Type - protected var variance = 1 + protected[core] var variance = 1 protected def derivedSelect(tp: NamedType, pre: Type): Type = tp.derivedSelect(pre) |