aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeApplications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-06-29 20:09:12 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-11 13:35:03 +0200
commitc28dd1b84ad611bb51e096f2a973c2157569ea86 (patch)
tree2e646742ab141240c806ac4230971b4536091352 /src/dotty/tools/dotc/core/TypeApplications.scala
parent02ce995f44c2252f7f7c0f07aa2a86f045b51ac2 (diff)
downloaddotty-c28dd1b84ad611bb51e096f2a973c2157569ea86.tar.gz
dotty-c28dd1b84ad611bb51e096f2a973c2157569ea86.tar.bz2
dotty-c28dd1b84ad611bb51e096f2a973c2157569ea86.zip
Tweaks to appliedTo
- Allow appliedTo over TypeBounds - Difference in handling of empty type parameter lists - Always consider EtaExpansions in appliedTo EtaExpanions were not simplified before in Coder.scala and collections.scala. Need to come back and simplify appliedTo logic.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index d7c73c63f..94e09eaf0 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -118,7 +118,8 @@ object TypeApplications {
*/
object EtaExpansion {
def apply(tycon: Type)(implicit ctx: Context) = {
- if (!Config.newHK) assert(tycon.isEtaExpandableOLD)
+ if (Config.newHK) assert(tycon.typeParams.nonEmpty, tycon)
+ else assert(tycon.isEtaExpandableOLD)
tycon.EtaExpand(tycon.typeParamSymbols)
}
@@ -729,13 +730,19 @@ class TypeApplications(val self: Type) extends AnyVal {
}
assert(args.nonEmpty)
self.stripTypeVar match {
- case self: TypeLambda if !args.exists(_.isInstanceOf[TypeBounds]) =>
- self.instantiate(args)
+ case self: TypeLambda =>
+ if (!args.exists(_.isInstanceOf[TypeBounds])) self.instantiate(args)
+ else self match {
+ case EtaExpansion(selfTycon) => selfTycon.appliedTo(args)
+ case _ => HKApply(self, args)
+ }
case self: AndOrType =>
self.derivedAndOrType(self.tp1.appliedTo(args), self.tp2.appliedTo(args))
+ case self: TypeBounds =>
+ self.derivedTypeBounds(self.lo, self.hi.appliedTo(args))
case self: LazyRef =>
LazyRef(() => self.ref.appliedTo(args, typParams))
- case _ if typParams.isEmpty || typParams.head.isInstanceOf[LambdaParam] =>
+ case _ if typParams.nonEmpty && typParams.head.isInstanceOf[LambdaParam] =>
HKApply(self, args)
case _ =>
matchParams(self, typParams, args) match {