From 053cd236ee12f877cfd71affb9a62a417f917d3d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 10 Apr 2017 16:35:01 +0200 Subject: 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 --- compiler/src/dotty/tools/dotc/core/TypeOps.scala | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'compiler/src/dotty/tools/dotc/core/TypeOps.scala') 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) } -- cgit v1.2.3