From 782c24ff51865e43e34a2485dc585a757ada2c3b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 21 Apr 2014 18:10:25 +0200 Subject: Changed handling of repeated parameters. Previously, repeated parameters were typed as `[T]`. The method `underlyingWithRepeated` converts `[T]` to `Seq[T]`. This method was called in typedIdent, but the call was ineffective because the type of a repeated parameter ident is a TermRef. This led to a retyping error in Decorators.scala under -Ycheck:front. We now distinguish between the type of the internal parameter ValDef and the type of the parameter in the MethodType. The former has the type `Seq[T] @dotty.annotation.internal.repeated`, the latter has the type `[T]`. The translation with `underlyingWithRepeated` thus becomes unneccessary. --- src/dotty/tools/dotc/core/Types.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 b17c40eb7..1107f184f 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -597,7 +597,7 @@ object Types { final def objToAny(implicit ctx: Context) = if ((this isRef defn.ObjectClass) && !ctx.phase.erasedTypes) defn.AnyType else this - /** If this is repeated parameter type, its underlying type, + /** If this is repeated parameter type, its underlying Seq type, * else the type itself. */ def underlyingIfRepeated(implicit ctx: Context): Type = this match { @@ -1316,7 +1316,7 @@ object Types { def withSymAndName(prefix: Type, sym: TermSymbol, name: TermName)(implicit ctx: Context): TermRef = if (prefix eq NoPrefix) withNonMemberSym(prefix, name, sym) - else if (sym.defRunId != NoRunId && sym.isCompleted) + else if (sym.defRunId != NoRunId && sym.isCompleted) withSig(prefix, name, sym.signature) withSym (sym, sym.signature) else apply(prefix, name) withSym (sym, Signature.NotAMethod) @@ -1664,9 +1664,15 @@ object Types { def apply(paramTypes: List[Type], resultType: Type)(implicit ctx: Context): MethodType = apply(nme.syntheticParamNames(paramTypes.length), paramTypes, resultType) def fromSymbols(params: List[Symbol], resultType: Type)(implicit ctx: Context) = { + def paramInfo(param: Symbol): Type = param.info match { + case AnnotatedType(annot, tp) if annot matches defn.RepeatedAnnot => + tp.translateParameterized(defn.SeqClass, defn.RepeatedParamClass) + case tp => + tp + } def transformResult(mt: MethodType) = resultType.subst(params, (0 until params.length).toList map (MethodParam(mt, _))) - apply(params map (_.name.asTermName), params map (_.info))(transformResult _) + apply(params map (_.name.asTermName), params map paramInfo)(transformResult _) } } -- cgit v1.2.3