aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-15 08:58:27 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-03 16:55:18 +0200
commit70bd06c81aa82e7b6ffd45d3d41e2817f0edb29b (patch)
treee7ddcb5ee315ee3af3308ca2f28f226b853839ee /src/dotty/tools/dotc/core/Types.scala
parent2f298924940453ec0ed15afd36da8c66bd7e80d1 (diff)
downloaddotty-70bd06c81aa82e7b6ffd45d3d41e2817f0edb29b.tar.gz
dotty-70bd06c81aa82e7b6ffd45d3d41e2817f0edb29b.tar.bz2
dotty-70bd06c81aa82e7b6ffd45d3d41e2817f0edb29b.zip
Eliminate JavaRepeatedParamClass
Having two repeated param classes (and two types) does not work, because we need to maintain an overriding relationship between Scala repeated param methods and Java repeated param methods (this will be resolved later by bridges).
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 8149cce78..a37b872d2 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -156,7 +156,7 @@ object Types {
/** Is this a type of a repeated parameter? */
def isRepeatedParam(implicit ctx: Context): Boolean =
- defn.RepeatedParamClasses contains typeSymbol
+ typeSymbol eq defn.RepeatedParamClass
/** Is this an alias TypeBounds? */
def isAlias: Boolean = this match {
@@ -623,11 +623,13 @@ object Types {
if ((this isRef defn.ObjectClass) && !ctx.phase.erasedTypes) defn.AnyType else this
/** If this is repeated parameter type, its underlying Seq type,
- * else the type itself.
+ * or, if isJava is true, Array type, else the type itself.
*/
- def underlyingIfRepeated(implicit ctx: Context): Type = this match {
- case rt @ RefinedType(tref: TypeRef, name) if defn.RepeatedParamClasses contains tref.symbol =>
- RefinedType(defn.SeqClass.typeRef, name, rt.refinedInfo)
+ def underlyingIfRepeated(isJava: Boolean)(implicit ctx: Context): Type = this match {
+ case rt @ RefinedType(tref: TypeRef, name) if tref.isRepeatedParam =>
+ RefinedType(
+ (if (isJava) defn.ArrayClass else defn.SeqClass).typeRef,
+ name, rt.refinedInfo)
case _ =>
this
}
@@ -867,7 +869,7 @@ object Types {
*/
def toFunctionType(implicit ctx: Context): Type = this match {
case mt @ MethodType(_, formals) if !mt.isDependent =>
- defn.FunctionType(formals mapConserve (_.underlyingIfRepeated), mt.resultType)
+ defn.FunctionType(formals mapConserve (_.underlyingIfRepeated(mt.isJava)), mt.resultType)
}
/** The signature of this type. This is by default NotAMethod,