Permalink
Browse files

#46 Fix constructor generation

  • Loading branch information...
1 parent b836234 commit 317afb110faae7e46c290fb0459d3a3d57c98224 @timowest committed Mar 14, 2013
@@ -49,10 +49,18 @@ class Constructors extends UnitTransformerBase {
t.getMembers.remove(c)
t.getMembers.add(t.getMembers.indexOf(constr(0)), c)
}
-
+
// copy initializer, if constructor block has non-constructor statements
val c = first.getOrElse(constr(0))
-
+
+ // add empty constructor invocation for all other constructors without
+ // constructor invocations
+ constr.filter(_ != c).foreach { c =>
+ if (c.getBlock.isEmpty) {// || !c.getBlock()(0).isInstanceOf[ConstructorInvocation]) {
+ c.getBlock.add(new ConstructorInvocation(true, null, null))
+ }
+ }
+
if (!c.getBlock.isEmpty &&
!c.getBlock.getStmts.filter(!_.isInstanceOf[ConstructorInvocation]).isEmpty) {
@@ -835,7 +835,7 @@ class ScalaDumpVisitor extends VoidVisitor[ScalaDumpVisitor.Context] with Helper
if (!first) {
printer.print("def this")
printTypeParameters(n.getTypeParameters, arg)
- }
+ }
printer.print("(")
if (n.getParameters != null) {
var lineBreaks = n.getParameters.size > 3
@@ -0,0 +1,16 @@
+package com.mysema.examples;
+
+class Base {
+
+ Base() {
+ }
+
+ Base(String s) {
+ }
+}
+
+class Derived extends Base {
+ Derived(String s) {
+ super(s);
+ }
+}

0 comments on commit 317afb1

Please sign in to comment.