#2457 super.trap() in Javascript

SlimerDude Wed 9 Sep 2015

I can't call super.trap() in Javascript and I'm not sure why. Calling it raised the Err:

sys::Type.toFanType: Not a Fantom type: sys::Obj

This simple test shows where the code fails:

@Js
class TestTrap : Test {
	
  Void testTrap() {
    this->toStr
  }
	
  override Obj? trap(Str name, Obj?[]? args := null) {
    retVal := super.trap(name, args)  // --> Err here
    // ... do other stuff
    return retVal
  }
}

The stacktrace:

fan.sys.Type.toFanType (sys.js:8834)
fan.sys.ObjUtil.trap (sys.js:12779)
fan.acme.TestTrap.trap (acme.js:999)

toFanType() looks like this:

fan.sys.Type.toFanType = function(obj)
{
  if (obj == null) throw fan.sys.Err.make("sys::Type.toFanType: obj is null");
  if (obj.$fanType != undefined) return obj.$fanType;
  if ((typeof obj) == "boolean" || obj instanceof Boolean) return fan.sys.Bool.$type;
  if ((typeof obj) == "number"  || obj instanceof Number)  return fan.sys.Int.$type;
  if ((typeof obj) == "string"  || obj instanceof String)  return fan.sys.Str.$type;
  throw fan.sys.Err.make("sys::Type.toFanType: Not a Fantom type: " + obj);
}

And ObjUtil.trap():

fan.sys.ObjUtil.trap = function(obj, name, args)
{
  if (obj instanceof fan.sys.Obj) return obj.trap(name, args);
  else return fan.sys.ObjUtil.doTrap(obj, name, args, fan.sys.Type.toFanType(obj));
}

Any ideas?

andy Wed 9 Sep 2015

Ticket promoted to #2457 and assigned to andy

Login or Signup to reply.