From 3290164f06715bbdf1cc2283b70e6234f74c3606 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 26 Jun 2015 17:08:04 +0200 Subject: Fix trait constructors Trait constructors added a this to the constructor of a trait, which is useless because the constructor's type is unit. By contrast, it's good to rename the DefDef to the new name. --- src/dotty/tools/dotc/transform/TraitConstructors.scala | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/transform/TraitConstructors.scala b/src/dotty/tools/dotc/transform/TraitConstructors.scala index 9fea468da..8c7277c2e 100644 --- a/src/dotty/tools/dotc/transform/TraitConstructors.scala +++ b/src/dotty/tools/dotc/transform/TraitConstructors.scala @@ -11,15 +11,12 @@ import dotty.tools.dotc.core._ import dotty.tools.dotc.transform.TreeTransforms.{MiniPhaseTransform, TransformerInfo} /*** - * Renames constructors in traits so that backend will call them with invokeInterface - * Also makes sure that renamed constructor bodies conforms to type of method + * Renames constructors in traits so that backend will call them with invokeInterface */ class TraitConstructors extends MiniPhaseTransform with SymTransformer { import dotty.tools.dotc.ast.tpd._ def phaseName: String = "traitConstructors" - override def treeTransformPhase: Phase = this.phase - def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = { if (sym.isPrimaryConstructor && (sym.owner is Flags.Trait)) sym.copySymDenotation(name = nme.IMPLCLASS_CONSTRUCTOR) @@ -29,8 +26,7 @@ class TraitConstructors extends MiniPhaseTransform with SymTransformer { override def transformDefDef(tree: tpd.DefDef)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = { val sym = tree.symbol if (sym.isPrimaryConstructor && (sym.owner is Flags.Trait)) - cpy.DefDef(tree)(rhs = Block(List(tree.rhs), This(tree.symbol.enclosingClass.asClass))) + cpy.DefDef(tree)(name = nme.IMPLCLASS_CONSTRUCTOR) else tree } - } -- cgit v1.2.3