Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Constructors w/ optional args don't generate the optional arg signatures #158

Open
baroquebobcat opened this Issue Dec 17, 2011 · 1 comment

Comments

Projects
None yet
1 participant
Owner

baroquebobcat commented Dec 17, 2011

class Foo
  def initialize x = 1
    @x = x
  end
  def bar z = 2
    @x+z
  end
end

produces

// Generated from foo.mirah
public class Foo extends java.lang.Object {
  private int x;
  public  Foo(int x) {
    this.x = x;
  }
  public int bar(int z) {
    return (this.x + z);
  }
  public int bar() {
    return this.bar(2);
  }
}

There should be a

 public  Foo() {
    Foo(1);
  }

in there.

I'm hoping to get to this this sunday.

Owner

baroquebobcat commented Dec 19, 2011

I didn't figure out how to do it yet, but the relevant code is in https://github.com/mirah/mirah/blob/master/lib/mirah/jvm/compiler/base.rb

Essentially, https://github.com/mirah/mirah/blob/master/lib/mirah/jvm/compiler/base.rb#L160-173 needs to act like https://github.com/mirah/mirah/blob/master/lib/mirah/jvm/compiler/base.rb#L131-156 for dealing with optional arguments.

I'm guessing though, that there may be other changes given that calling constructors in constructors is different than calling methods from methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment