From 91e44df57185a32988c22823551d8049b3c43da8 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 19 Jun 2014 13:41:18 +0200 Subject: Fixes to lambda abstraction 1) Honor variance of Apply and $hkArgs when instantiating them 2) Eta-lifting a higher-kinded type is straight eta expansion, no arguments are applied. --- src/dotty/tools/dotc/core/Types.scala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 794f05319..718d01ebe 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2096,6 +2096,13 @@ object Types { if (lo eq tp) this else TypeAlias(tp, variance) + /** If this is an alias, a derived alias with the new variance, + * Otherwise the type itself. + */ + def withVariance(variance: Int)(implicit ctx: Context) = + if (lo ne hi) this + else derivedTypeBounds(lo, hi, variance) + def contains(tp: Type)(implicit ctx: Context) = tp match { case tp: TypeBounds => lo <:< tp.lo && tp.hi <:< hi case _ => lo <:< tp && tp <:< hi -- cgit v1.2.3