diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/TypeErasure.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 7 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeApplications.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 4 |
4 files changed, 14 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/TypeErasure.scala b/src/dotty/tools/dotc/TypeErasure.scala index 81369f28d..1786e2e29 100644 --- a/src/dotty/tools/dotc/TypeErasure.scala +++ b/src/dotty/tools/dotc/TypeErasure.scala @@ -95,10 +95,9 @@ object TypeErasure { def erasure(tp: Type)(implicit ctx: Context): Type = scalaErasureFn(tp)(erasureCtx) def semiErasure(tp: Type)(implicit ctx: Context): Type = semiErasureFn(tp)(erasureCtx) def sigName(tp: Type, isJava: Boolean)(implicit ctx: Context): TypeName = { + val seqClass = if(isJava) defn.ArrayClass else defn.SeqClass val normTp = - if (tp.isRepeatedParam) - if (isJava) tp.translateParameterized(defn.RepeatedParamClass, defn.ArrayClass) - else tp.translateParameterized(defn.RepeatedParamClass, defn.SeqClass) + if (tp.isRepeatedParam) tp.translateParameterized(defn.RepeatedParamClass, seqClass) else tp (if (isJava) javaSigFn else scalaSigFn).sigName(normTp)(erasureCtx) } diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index b7786e00c..1aab16469 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -771,11 +771,12 @@ object desugar { else // l.op(r), or val x = r; l.op(x), plus handle named args specially makeBinop(l, op, r) case PostfixOp(t, op) => - if ((ctx.mode is Mode.Type) && op == nme.raw.STAR) + if ((ctx.mode is Mode.Type) && op == nme.raw.STAR) { + val seqClass = if (ctx.compilationUnit.isJava) defn.ArrayClass else defn.SeqClass Annotated( New(ref(defn.RepeatedAnnot.typeRef), Nil :: Nil), - AppliedTypeTree(ref(defn.SeqClass.typeRef), t)) - else { + AppliedTypeTree(ref(seqClass.typeRef), t)) + } else { assert(ctx.mode.isExpr, ctx.mode) Select(t, op) } diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 3808cb17c..3beb680d9 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -283,12 +283,12 @@ class TypeApplications(val self: Type) extends AnyVal { /** If this is repeated parameter type, its underlying Seq type, * or, if isJava is true, Array type, else the type itself. */ - def underlyingIfRepeated(isJava: Boolean)(implicit ctx: Context): Type = { - if (self.isRepeatedParam) - if (isJava) translateParameterized(defn.RepeatedParamClass, defn.ArrayClass) - else translateParameterized(defn.RepeatedParamClass, defn.SeqClass) + def underlyingIfRepeated(isJava: Boolean)(implicit ctx: Context): Type = + if (self.isRepeatedParam) { + val seqClass = if(isJava) defn.ArrayClass else defn.SeqClass + translateParameterized(defn.RepeatedParamClass, seqClass) + } else self - } /** If this is an encoding of a (partially) applied type, return its arguments, * otherwise return Nil. diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 601870e55..2997e9e77 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1974,7 +1974,9 @@ object Types { 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) + val typeSym = param.info.typeSymbol.asClass + assert(typeSym == defn.SeqClass || typeSym == defn.ArrayClass) + tp.translateParameterized(typeSym, defn.RepeatedParamClass) case tp => tp } |