Skip to content

Fix for inherited external class, with full path of the class.

When an inherited class is from an external class, with multi-levels, the code generated don't load the info of external class correctly. The sample code:

unit Main;

{$modeswitch externalclass}

interface

type
  TMyClass = class external name 'A'
  public type
    TMyClass = class external name 'B'
    public type
      TMyClass = class external name 'C' (TJSObject)
      public
        constructor New(aaa: INteger);
      end;
    end;
  end;

  TMyAnotherClass = class(TMyClass.TMyClass.TMyClass)
  end;

procedure Error;

implementation

procedure Error;
begin
  TMyAnotherClass.Create;
end;

end.

The generated code is this:

rtl.module("Main",["System"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$ExtClass("TMyClass",{jsclass: "A"});
  this.$rtti.$ExtClass("TMyClass.TMyClass",{jsclass: "B"});
  this.$rtti.$ExtClass("TMyClass.TMyClass.TMyClass",{jsclass: "C"});
  rtl.createClassExt(this,"TMyAnotherClass",C,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
});

And must be like this:

rtl.module("Main",["System"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$ExtClass("TMyClass",{jsclass: "A"});
  this.$rtti.$ExtClass("TMyClass.TMyClass",{jsclass: "B"});
  this.$rtti.$ExtClass("TMyClass.TMyClass.TMyClass",{jsclass: "C"});
  rtl.createClassExt(this,"TMyAnotherClass",A.B.C,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
});

Merge request reports