From 70bd06c81aa82e7b6ffd45d3d41e2817f0edb29b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Jul 2014 08:58:27 +0200 Subject: 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). --- src/dotty/tools/dotc/core/Types.scala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') 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, -- cgit v1.2.3