Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Open
baroquebobcat opened this Issue · 1 comment

1 participant

@baroquebobcat
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.

@baroquebobcat

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
Something went wrong with that request. Please try again.