diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-11 17:01:30 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-11-11 17:01:30 +0100 |
commit | 49cef124a7be97647db3ccdbb0b775f53e5265d0 (patch) | |
tree | 4c8bd34a5f8050890adb409821c0c4023195500f /src/dotty/tools/dotc/core | |
parent | 49022717bc0e8c0de8834f4cde5021e1da8c0ea0 (diff) | |
download | dotty-49cef124a7be97647db3ccdbb0b775f53e5265d0.tar.gz dotty-49cef124a7be97647db3ccdbb0b775f53e5265d0.tar.bz2 dotty-49cef124a7be97647db3ccdbb0b775f53e5265d0.zip |
Replace PolyType.fromSymbols with LambdaAbstract
As a side effect, avoid creating synthetic parameters in lambda abstract.
Diffstat (limited to 'src/dotty/tools/dotc/core')
4 files changed, 10 insertions, 29 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 8aaf77032..70819e590 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -340,10 +340,11 @@ class TypeApplications(val self: Type) extends AnyVal { def LambdaAbstract(tparams: List[TypeParamInfo])(implicit ctx: Context): Type = { def expand(tp: Type) = PolyType( - tpnme.syntheticLambdaParamNames(tparams.length), tparams.map(_.paramVariance))( + tparams.map(_.paramName), tparams.map(_.paramVariance))( tl => tparams.map(tparam => tl.lifted(tparams, tparam.paramBounds).bounds), tl => tl.lifted(tparams, tp)) - self match { + if (tparams.isEmpty) self + else self match { case self: TypeAlias => self.derivedTypeAlias(expand(self.alias)) case self @ TypeBounds(lo, hi) => diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index ce308412b..a90fec2b4 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2524,7 +2524,7 @@ object Types { case _: MethodType => true case _ => false } - + /** Is this polytype a higher-kinded type lambda as opposed to a polymorphic? * method type? Only type lambdas get created with variances, that's how we can tell. */ @@ -2619,12 +2619,6 @@ object Types { unique(new PolyType(paramNames, vs)(paramBoundsExp, resultTypeExp)) } - def fromSymbols(tparams: List[Symbol], resultType: Type)(implicit ctx: Context): Type = - if (tparams.isEmpty) resultType - else apply(tparams map (_.name.asTypeName), tparams.map(_.variance))( - pt => tparams.map(tparam => pt.lifted(tparams, tparam.info).bounds), - pt => pt.lifted(tparams, resultType)) - def unapply(tl: PolyType): Some[(List[LambdaParam], Type)] = Some((tl.typeParams, tl.resType)) diff --git a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 1570dbca0..97a82e80d 100644 --- a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -217,7 +217,7 @@ class ClassfileParser( if (isEnum) denot.info = ConstantType(Constant(sym)) if (isConstructor) stripOuterParamFromConstructor() setPrivateWithin(denot, jflags) - denot.info = depoly(parseAttributes(sym, denot.info), denot) + denot.info = translateTempPoly(parseAttributes(sym, denot.info)) if (isConstructor) normalizeConstructorInfo() if ((denot is Flags.Method) && (jflags & JAVA_ACC_VARARGS) != 0) diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 70148b3e2..b01f6cc6a 100644 --- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -40,29 +40,15 @@ object Scala2Unpickler { /** Temporary type for classinfos, will be decomposed on completion of the class */ case class TempClassInfoType(parentTypes: List[Type], decls: Scope, clazz: Symbol) extends UncachedGroundType - /** Convert temp poly type to some native Dotty idiom. - * @param denot The denotation that gets the converted type as info. - * If `denot` is not an abstract type, this simply returns an equivalent `PolyType`. - * If `denot` is an abstract type, it converts a - * - * TempPolyType(List(v_1 T_1, ..., v_n T_n), lo .. hi) - * - * to a type lambda using `parameterizeWith/LambdaAbstract`. - */ - def depoly(tp: Type, denot: SymDenotation)(implicit ctx: Context): Type = tp match { - case TempPolyType(tparams, restpe) => - if (denot.isType) { - assert(!denot.isClass) - restpe.LambdaAbstract(tparams) - } - else - PolyType.fromSymbols(tparams, restpe) + /** Convert temp poly type to poly type and leave other types alone. */ + def translateTempPoly(tp: Type)(implicit ctx: Context): Type = tp match { + case TempPolyType(tparams, restpe) => restpe.LambdaAbstract(tparams) case tp => tp } def addConstructorTypeParams(denot: SymDenotation)(implicit ctx: Context) = { assert(denot.isConstructor) - denot.info = PolyType.fromSymbols(denot.owner.typeParams, denot.info) + denot.info = denot.info.LambdaAbstract(denot.owner.typeParams) } /** Convert array parameters denoting a repeated parameter of a Java method @@ -549,7 +535,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas val selfInfo = if (atEnd) NoType else readTypeRef() setClassInfo(denot, tp, selfInfo) case denot => - val tp1 = depoly(tp, denot) + val tp1 = translateTempPoly(tp) denot.info = if (tag == ALIASsym) TypeAlias(tp1) else if (denot.isType) checkNonCyclic(denot.symbol, tp1, reportErrors = false) |