diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-19 19:04:03 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-06 13:15:29 +0200 |
commit | 15e60e8637887892b0c03e5f6948f1222819a746 (patch) | |
tree | c159c408a26025212d77baac11971291101d9870 | |
parent | 8d33ca7460493427055daaecca53c66127772831 (diff) | |
download | dotty-15e60e8637887892b0c03e5f6948f1222819a746.tar.gz dotty-15e60e8637887892b0c03e5f6948f1222819a746.tar.bz2 dotty-15e60e8637887892b0c03e5f6948f1222819a746.zip |
Narrow matches from TypeLambda to HKTypeLambda where appropriate
4 files changed, 10 insertions, 8 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index 1882489a5..23c3f96cc 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -215,7 +215,7 @@ class TypeApplications(val self: Type) extends AnyVal { self match { case self: ClassInfo => self.cls.typeParams - case self: TypeLambda => + case self: HKTypeLambda => self.typeParams case self: TypeRef => val tsym = self.symbol @@ -386,7 +386,7 @@ class TypeApplications(val self: Type) extends AnyVal { val dealiased = stripped.safeDealias if (args.isEmpty || ctx.erasedTypes) self else dealiased match { - case dealiased: TypeLambda => + case dealiased: HKTypeLambda => def tryReduce = if (!args.exists(_.isInstanceOf[TypeBounds])) { val followAlias = Config.simplifyApplications && { @@ -414,6 +414,8 @@ class TypeApplications(val self: Type) extends AnyVal { else HKApply(dealiased, args) } tryReduce + case dealiased: PolyType => + dealiased.instantiate(args) case dealiased: AndOrType => dealiased.derivedAndOrType(dealiased.tp1.appliedTo(args), dealiased.tp2.appliedTo(args)) case dealiased: TypeAlias => diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 173520a10..da6d63387 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -430,7 +430,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { compareHkApply2(tp1, tp2, tycon2, args2) case tp2: HKTypeLambda => def compareTypeLambda: Boolean = tp1.stripTypeVar match { - case tp1: TypeLambda => + case tp1: HKTypeLambda => /* Don't compare bounds of lambdas under language:Scala2, or t2994 will fail * The issue is that, logically, bounds should compare contravariantly, * but that would invalidate a pattern exploited in t2994: diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index dd314c589..fc6d5f44c 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -539,7 +539,7 @@ object Types { } def goApply(tp: HKApply) = tp.tycon match { - case tl: TypeLambda => + case tl: HKTypeLambda => go(tl.resType).mapInfo(info => tl.derivedLambdaAbstraction(tl.paramNames, tl.paramInfos, info).appliedTo(tp.args)) case _ => @@ -2830,7 +2830,7 @@ object Types { override def superType(implicit ctx: Context): Type = { if (ctx.period != validSuper) { cachedSuper = tycon match { - case tp: TypeLambda => defn.AnyType + case tp: HKTypeLambda => defn.AnyType case tp: TypeVar if !tp.inst.exists => // supertype not stable, since underlying might change return tp.underlying.applyIfParameterized(args) diff --git a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala index 48da9f35f..632dbff76 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala @@ -121,9 +121,9 @@ object Inferencing { /** If `tree` has a type lambda type, infer its type parameters by comparing with expected type `pt` */ def inferTypeParams(tree: Tree, pt: Type)(implicit ctx: Context): Tree = tree.tpe match { - case poly: TypeLambda => - val (poly1, tvars) = constrained(poly, tree) - val tree1 = tree.withType(poly1).appliedToTypeTrees(tvars) + case tl: TypeLambda => + val (tl1, tvars) = constrained(tl, tree) + val tree1 = tree.withType(tl1).appliedToTypeTrees(tvars) tree1.tpe <:< pt fullyDefinedType(tree1.tpe, "template parent", tree.pos) tree1 |