aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeApplications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-04-24 18:04:09 +0200
committerMartin Odersky <odersky@gmail.com>2015-04-24 18:04:09 +0200
commit6a3aab8241cc5379bcffb7644bdbaa04ba12ce5b (patch)
tree80d4fa10baf4b1530963b2366fa4c420e68adeb4 /src/dotty/tools/dotc/core/TypeApplications.scala
parent1e9c012a0c61b2031ecaf11de3f2e99a5fdff7af (diff)
downloaddotty-6a3aab8241cc5379bcffb7644bdbaa04ba12ce5b.tar.gz
dotty-6a3aab8241cc5379bcffb7644bdbaa04ba12ce5b.tar.bz2
dotty-6a3aab8241cc5379bcffb7644bdbaa04ba12ce5b.zip
Allow byname repated parameters
Implements #499
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index de42b3e5f..a5e24c5ff 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -279,15 +279,20 @@ class TypeApplications(val self: Type) extends AnyVal {
default
}
}
-
+
/** Translate a type of the form From[T] to To[T], keep other types as they are.
* `from` and `to` must be static classes, both with one type parameter, and the same variance.
+ * Do the same for by name types => From[T] and => To[T]
*/
- def translateParameterized(from: ClassSymbol, to: ClassSymbol)(implicit ctx: Context): Type =
- if (self.derivesFrom(from))
- if (ctx.erasedTypes) to.typeRef
- else RefinedType(to.typeRef, to.typeParams.head.name, self.member(from.typeParams.head.name).info)
- else self
+ def translateParameterized(from: ClassSymbol, to: ClassSymbol)(implicit ctx: Context): Type = self match {
+ case self @ ExprType(tp) =>
+ self.derivedExprType(tp.translateParameterized(from, to))
+ case _ =>
+ if (self.derivesFrom(from))
+ if (ctx.erasedTypes) to.typeRef
+ else RefinedType(to.typeRef, to.typeParams.head.name, self.member(from.typeParams.head.name).info)
+ else self
+ }
/** If this is repeated parameter type, its underlying Seq type,
* or, if isJava is true, Array type, else the type itself.