aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeApplications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-28 13:07:22 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-03-31 14:52:08 +0200
commita73b510b82460247524a07a6dd4f0bfaac74ccfc (patch)
treec3b6ab1e6159d31cfda21b5011577b98ef745e3f /src/dotty/tools/dotc/core/TypeApplications.scala
parente5d51859bd3d6fd0b286aa6c8e710f33f95b97cd (diff)
downloaddotty-a73b510b82460247524a07a6dd4f0bfaac74ccfc.tar.gz
dotty-a73b510b82460247524a07a6dd4f0bfaac74ccfc.tar.bz2
dotty-a73b510b82460247524a07a6dd4f0bfaac74ccfc.zip
Avoiding type applications after erasure.
Methods appliedTo and translateParameterizes only apply before erasure (except on arrays). Also, computation of a potential expensive yet redundant lub in assignType(SeqLiteral) is avoided.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index 9cd635cd9..4b251f183 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -39,6 +39,8 @@ import TypeApplications._
/** A decorator that provides methods for modeling type application */
class TypeApplications(val self: Type) extends AnyVal {
+ def canHaveTypeParams(implicit ctx: Context) = !ctx.erasedTypes || self.isRef(defn.ArrayClass)
+
/** The type parameters of this type are:
* For a ClassInfo type, the type parameters of its class.
* For a typeref referring to a class, the type parameters of the class.
@@ -128,7 +130,7 @@ class TypeApplications(val self: Type) extends AnyVal {
defn.hkTrait(args map alwaysZero).typeParams
}
- if (args.isEmpty) self
+ if (args.isEmpty || !canHaveTypeParams) self
else self match {
case tp: TypeRef =>
val tsym = tp.symbol
@@ -228,8 +230,11 @@ class TypeApplications(val self: Type) extends AnyVal {
* `from` and `to` must be static classes, both with one type parameter, and the same variance.
*/
def translateParameterized(from: ClassSymbol, to: ClassSymbol)(implicit ctx: Context): Type =
- if (self derivesFrom from)
- RefinedType(to.typeRef, to.typeParams.head.name, self.member(from.typeParams.head.name).info)
+ if (self.derivesFrom(from))
+ if (canHaveTypeParams)
+ RefinedType(to.typeRef, to.typeParams.head.name, self.member(from.typeParams.head.name).info)
+ else
+ to.typeRef
else self
/** If this is an encoding of a (partially) applied type, return its arguments,