diff options
author | Martin Odersky <odersky@gmail.com> | 2014-04-21 18:10:25 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-05-08 21:51:46 +0200 |
commit | 782c24ff51865e43e34a2485dc585a757ada2c3b (patch) | |
tree | b4aab29f24af18dd4ab428c2e8169cf8fc320be2 /src/dotty/tools/dotc/core/Types.scala | |
parent | 35366df3bed1e2a13aa41abfd0f75c7241f22197 (diff) | |
download | dotty-782c24ff51865e43e34a2485dc585a757ada2c3b.tar.gz dotty-782c24ff51865e43e34a2485dc585a757ada2c3b.tar.bz2 dotty-782c24ff51865e43e34a2485dc585a757ada2c3b.zip |
Changed handling of repeated parameters.
Previously, repeated parameters were typed as `<repeated>[T]`. The
method `underlyingWithRepeated` converts `<repeated>[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
`<repeated>[T]`. The translation with `underlyingWithRepeated` thus
becomes unneccessary.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 12 |
1 files changed, 9 insertions, 3 deletions
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 _) } } |