diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-11 22:20:24 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-11-11 22:20:24 +0100 |
commit | 97b6985c34915b58e0c81fbab464f4bd532c27d0 (patch) | |
tree | 968795a36f2eb50791166f8288a8d5ad1f72c285 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | f3c8fdddcc7a5aef1c206afb0942d4a961ef1186 (diff) | |
download | dotty-97b6985c34915b58e0c81fbab464f4bd532c27d0.tar.gz dotty-97b6985c34915b58e0c81fbab464f4bd532c27d0.tar.bz2 dotty-97b6985c34915b58e0c81fbab464f4bd532c27d0.zip |
Clean up parameterized typedefs
Express them in terms PolyTypeTrees rather than having an
irregular, untyped only tparams field. This is necessary
if we want to pickle type trees instead of types, because
now the rhs of a typedef tells the whole story, so we are not
required any longer to use the info of the symbol.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 6b69a859e..a72c1d5f2 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -1185,7 +1185,15 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedTypeDef(tdef: untpd.TypeDef, sym: Symbol)(implicit ctx: Context): Tree = track("typedTypeDef") { val TypeDef(name, rhs) = tdef completeAnnotations(tdef, sym) - assignType(cpy.TypeDef(tdef)(name, typedType(rhs), Nil), sym) + val rhs1 = tdef.rhs match { + case rhs @ PolyTypeTree(tparams, body) => + val tparams1 = tparams.map(typed(_)).asInstanceOf[List[TypeDef]] + val body1 = typedType(body) + assignType(cpy.PolyTypeTree(rhs)(tparams1, body1), tparams1, body1) + case rhs => + typedType(rhs) + } + assignType(cpy.TypeDef(tdef)(name, rhs1), sym) } def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(implicit ctx: Context) = track("typedClassDef") { @@ -1250,7 +1258,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit .withType(dummy.nonMemberTermRef) checkVariance(impl1) if (!cls.is(AbstractOrTrait) && !ctx.isAfterTyper) checkRealizableBounds(cls.typeRef, cdef.namePos) - val cdef1 = assignType(cpy.TypeDef(cdef)(name, impl1, Nil), cls) + val cdef1 = assignType(cpy.TypeDef(cdef)(name, impl1), cls) if (ctx.phase.isTyper && cdef1.tpe.derivesFrom(defn.DynamicClass) && !ctx.dynamicsEnabled) { val isRequired = parents1.exists(_.tpe.isRef(defn.DynamicClass)) ctx.featureWarning(nme.dynamics.toString, "extension of type scala.Dynamic", isScala2Feature = true, |