diff options
author | Martin Odersky <odersky@gmail.com> | 2014-06-19 13:41:18 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-06-19 13:41:18 +0200 |
commit | 91e44df57185a32988c22823551d8049b3c43da8 (patch) | |
tree | 79d73bb9f528b2f635cb1d8487e4c8a8a5756690 /src/dotty/tools/dotc/core/Types.scala | |
parent | 76238566c281b9d87b17c7e361feb649ceb7a6d0 (diff) | |
download | dotty-91e44df57185a32988c22823551d8049b3c43da8.tar.gz dotty-91e44df57185a32988c22823551d8049b3c43da8.tar.bz2 dotty-91e44df57185a32988c22823551d8049b3c43da8.zip |
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.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 7 |
1 files changed, 7 insertions, 0 deletions
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 |