[java] Closure in constructor breaks assumption #2688

Closed
singpolyma opened this Issue Feb 28, 2014 · 3 comments

Comments

Projects
None yet
4 participants
Contributor

singpolyma commented Feb 28, 2014

The following code says "Types that derive from a native class must have its super() call as the first statement in the constructor" and generates code where the extra variables generated for the closure come before the super call, even though the super call is clearly first in my code:

private enum Unit {
   Unit;
}

class AsyncTask<A> extends android.os.AsyncTask<A,Unit,Unit> {
   private var task:Array<A> -> Void;

   public function new(tsk:Void -> Void) {
      super();
      task = function(x) {
         tsk();
      };
   }
}

waneck self-assigned this Mar 1, 2014

Owner

waneck commented Mar 3, 2014

Can you provide an example with no dependencies?

Contributor

singpolyma commented Mar 3, 2014

Sure:

class Main<A> extends java.lang.Object {
   private var task:Array<A> -> Void;
   public function new(tsk:Void -> Void) {
      super();
      task = function(x) {
         tsk();
      };
   }
}
Owner

Simn commented Mar 3, 2014

I guess that's an issue on all WrapRef targets?

ncannasse added this to the 3.2 milestone Mar 4, 2014

@waneck waneck modified the milestone: 3.3, 3.2 Sep 8, 2014

@Simn Simn modified the milestone: 3.3.0-rc1, 3.4 Feb 23, 2016

@Simn Simn modified the milestone: 3.4, 4.0 Jan 9, 2017

waneck closed this in bb00338 Jun 25, 2017

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