#2500 JS Abstract Main Support

go4 Sun 20 Dec 2015

My code like this:

@Js
abstract class BaseMain {
  abstract Void foo()
  Void main() { foo() }
}

@Js
class Main : BaseMain {
  override Void foo() { echo("Hi") }
}

The error message: Uncaught TypeError: this.foo is not a function as result of WebUtil::jsMain

// find main
var qname = 'MainTest::Main';
var dot = qname.indexOf('.');
if (dot < 0) qname += '.main';
var main = fan.sys.Slot.findMethod(qname);

// invoke main
if (main.isStatic()) main.call();
else main.callOn(main.parent().make());
                       ^----make an instance of 'BaseMain'

andy Mon 21 Dec 2015

Ticket promoted to #2500 and assigned to andy

Login or Signup to reply.