aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Desugar.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-01 13:17:05 +0100
committerMartin Odersky <odersky@gmail.com>2014-03-01 13:41:00 +0100
commitd8356b6dc9221bfc38b1f167e5cfafcc9261f3d7 (patch)
tree3bb6fda0feb33680f68f61908a7076162159701e /src/dotty/tools/dotc/ast/Desugar.scala
parent5a8f4c822be82e23a0c230071673425423664442 (diff)
downloaddotty-d8356b6dc9221bfc38b1f167e5cfafcc9261f3d7.tar.gz
dotty-d8356b6dc9221bfc38b1f167e5cfafcc9261f3d7.tar.bz2
dotty-d8356b6dc9221bfc38b1f167e5cfafcc9261f3d7.zip
Reorganization of template parents.
Template parents always were constructor calls before. This is not correct because in a situation like the one elaborated in templateParents, the trait D has the class C as supertype, but it does not call its constructor (in fact, if we added a () parameter list to make it into a constructor this would be wrong because C takes parameters. Now parents can be either types or constructor calls. The logic in Namer and Typer that deals with parents is cleaned up. In particular, we now construct any synthetic class parent as a full type, before calling normalizeToClassRefs. This obviates the forwardRefs logic that needed to be done in a cleanup of Namers. Also added two more checks: (1) All parents except the first one must point to traits. (2) A trait may not call a parent class constructor.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 0f1d1010a..473800cde 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -226,7 +226,7 @@ object desugar {
def productConstr(n: Int) = {
val tycon = ref(defn.ProductNClass(n).typeRef)
val targs = vparamss.head map (_.tpt)
- New(AppliedTypeTree(tycon, targs), Nil)
+ AppliedTypeTree(tycon, targs)
}
// Case classes get a ProductN parent
@@ -241,7 +241,7 @@ object desugar {
moduleDef(
ModuleDef(
Modifiers(Synthetic), name.toTermName,
- Template(emptyConstructor, New(parentTpt, Nil) :: Nil, EmptyValDef, defs))).toList
+ Template(emptyConstructor, parentTpt :: Nil, EmptyValDef, defs))).toList
// The companion object defifinitions, if a companion is needed, Nil otherwise.
// companion definitions include:
@@ -713,13 +713,13 @@ object desugar {
/** Create a class definition with the same info as this refined type.
* parent { refinements }
* ==>
- * class <refinement> extends parent { refinements }
+ * trait <refinement> extends parent { refinements }
*
* The result is used for validity checking, is thrown away afterwards.
*/
def refinedTypeToClass(tree: RefinedTypeTree)(implicit ctx: Context): TypeDef = {
val impl = Template(emptyConstructor, tree.tpt :: Nil, EmptyValDef, tree.refinements)
- TypeDef(Modifiers(), tpnme.REFINE_CLASS, impl)
+ TypeDef(Modifiers(Trait), tpnme.REFINE_CLASS, impl)
}
/** If tree is a variable pattern, return its name and type, otherwise return None.