aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-11-11 17:01:30 +0100
committerMartin Odersky <odersky@gmail.com>2016-11-11 17:01:30 +0100
commit49cef124a7be97647db3ccdbb0b775f53e5265d0 (patch)
tree4c8bd34a5f8050890adb409821c0c4023195500f /src/dotty/tools
parent49022717bc0e8c0de8834f4cde5021e1da8c0ea0 (diff)
downloaddotty-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')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala5
-rw-r--r--src/dotty/tools/dotc/core/Types.scala8
-rw-r--r--src/dotty/tools/dotc/core/classfile/ClassfileParser.scala2
-rw-r--r--src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala24
-rw-r--r--src/dotty/tools/dotc/typer/Inliner.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala2
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala4
7 files changed, 14 insertions, 33 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)
diff --git a/src/dotty/tools/dotc/typer/Inliner.scala b/src/dotty/tools/dotc/typer/Inliner.scala
index 6499167ad..f6616d329 100644
--- a/src/dotty/tools/dotc/typer/Inliner.scala
+++ b/src/dotty/tools/dotc/typer/Inliner.scala
@@ -120,7 +120,7 @@ object Inliner {
// Abstract accessed type over local refs
def abstractQualType(mtpe: Type): Type =
if (localRefs.isEmpty) mtpe
- else PolyType.fromSymbols(localRefs.map(_.symbol), mtpe).asInstanceOf[PolyType].flatten
+ else mtpe.LambdaAbstract(localRefs.map(_.symbol)).asInstanceOf[PolyType].flatten
val accessorType = abstractQualType(addQualType(dealiasMap(accessedType)))
val accessor = accessorSymbol(tree, accessorType).asTerm
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index dd7326fae..77f8ff786 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -113,7 +113,7 @@ trait NamerContextOps { this: Context =>
if (param.info.isDirectRef(defn.ObjectClass)) param.info = defn.AnyType
make.fromSymbols(params, resultType)
}
- if (typeParams.nonEmpty) PolyType.fromSymbols(typeParams, monotpe)
+ if (typeParams.nonEmpty) monotpe.LambdaAbstract(typeParams)
else if (valueParamss.isEmpty) ExprType(monotpe)
else monotpe
}
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 259b3b83e..1599d95e6 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -431,7 +431,7 @@ trait TypeAssigner {
def assignType(tree: untpd.OrTypeTree, left: Tree, right: Tree)(implicit ctx: Context) =
tree.withType(left.tpe | right.tpe)
- /** Assign type of RefinedType.
+ /** Assign type of RefinedType.
* Refinements are typed as if they were members of refinement class `refineCls`.
*/
def assignType(tree: untpd.RefinedTypeTree, parent: Tree, refinements: List[Tree], refineCls: ClassSymbol)(implicit ctx: Context) = {
@@ -467,7 +467,7 @@ trait TypeAssigner {
}
def assignType(tree: untpd.PolyTypeTree, tparamDefs: List[TypeDef], body: Tree)(implicit ctx: Context) =
- tree.withType(PolyType.fromSymbols(tparamDefs.map(_.symbol), body.tpe))
+ tree.withType(body.tpe.LambdaAbstract(tparamDefs.map(_.symbol)))
def assignType(tree: untpd.ByNameTypeTree, result: Tree)(implicit ctx: Context) =
tree.withType(ExprType(result.tpe))