aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
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
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')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala5
-rw-r--r--src/dotty/tools/dotc/core/StdNames.scala1
-rw-r--r--src/dotty/tools/dotc/core/Types.scala14
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala4
4 files changed, 10 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 594f0c013..9c479de73 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -235,7 +235,6 @@ class Definitions {
lazy val EqualsPatternClass = specialPolyClass(tpnme.EQUALS_PATTERN, EmptyFlags, AnyType)
lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS, Covariant, SeqType)
- lazy val JavaRepeatedParamClass = specialPolyClass(tpnme.JAVA_REPEATED_PARAM_CLASS, Covariant, ArrayClass.typeRef)
// fundamental classes
lazy val StringClass = ctx.requiredClass("java.lang.String")
@@ -327,7 +326,6 @@ class Definitions {
def PairType: Type = PairClass.typeRef
def StringType: Type = StringClass.typeRef
def RepeatedParamType = RepeatedParamClass.typeRef
- def JavaRepeatedParamType = JavaRepeatedParamClass.typeRef
def ThrowableType = ThrowableClass.typeRef
def OptionType = OptionClass.typeRef
def VolatileAnnotType = VolatileAnnot.typeRef
@@ -396,8 +394,6 @@ class Definitions {
lazy val TupleClasses: Set[Symbol] = TupleClass.toSet
lazy val ProductClasses: Set[Symbol] = ProductNClass.toSet
- lazy val RepeatedParamClasses: Set[Symbol] = Set(RepeatedParamClass, JavaRepeatedParamClass)
-
/** `Modules whose members are in the default namespace and their module classes */
lazy val UnqualifiedOwners = RootImports.toSet ++ RootImports.map(_.moduleClass)
@@ -554,7 +550,6 @@ class Definitions {
AnyClass,
AnyRefAlias,
RepeatedParamClass,
- JavaRepeatedParamClass,
ByNameParamClass2x,
AnyValClass,
NullClass,
diff --git a/src/dotty/tools/dotc/core/StdNames.scala b/src/dotty/tools/dotc/core/StdNames.scala
index 3ab0ec36e..91a77a2a8 100644
--- a/src/dotty/tools/dotc/core/StdNames.scala
+++ b/src/dotty/tools/dotc/core/StdNames.scala
@@ -160,7 +160,6 @@ object StdNames {
final val BYNAME_PARAM_CLASS: N = "<byname>"
final val EQUALS_PATTERN: N = "<equals>"
- final val JAVA_REPEATED_PARAM_CLASS: N = "<repeated...>"
final val LOCAL_CHILD: N = "<local child>"
final val REPEATED_PARAM_CLASS: N = "<repeated>"
final val WILDCARD_STAR: N = "_*"
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,
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 36b2c99bf..de3f626da 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -70,7 +70,7 @@ object UnPickler {
}
/** Convert array parameters denoting a repeated parameter of a Java method
- * to `JavaRepeatedParamClass` types.
+ * to `RepeatedParamClass` types.
*/
def arrayToRepeated(tp: Type)(implicit ctx: Context): Type = tp match {
case tp @ MethodType(paramNames, paramTypes) =>
@@ -85,7 +85,7 @@ object UnPickler {
}
tp.derivedMethodType(
paramNames,
- paramTypes.init :+ defn.JavaRepeatedParamType.appliedTo(elemtp),
+ paramTypes.init :+ defn.RepeatedParamType.appliedTo(elemtp),
tp.resultType)
case tp @ PolyType(paramNames) =>
tp.derivedPolyType(paramNames, tp.paramBounds, arrayToRepeated(tp.resultType))