Forum > Editor

Completion Box: no protected inherited content when using pointer to object

(1/1)

furious programming:
One program unit declares an object (good old object, not a class) containing protected fields. This is the base object type from which others can inherit. For example:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Base; {$mode ObjFPC}{$H+} interface type  PBase = ^TBase;  TBase = object  protected    X: Integer;    Y: Integer;  end; implementation end.
In another unit there is a declaration of another object that inherits from this base one. In addition to the data type, there is also a procedure that takes a pointer to the final object and modifies the object's data — there is access to all fields, including inherited ones. For example:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Something; {$mode ObjFPC}{$H+} interface uses  Base; type  PSomething = ^TSomething;  TSomething = object(TBase)  protected    A: Integer;    B: Integer;  end;   procedure DoSomething(ASomething: PSomething); implementation procedure DoSomething(ASomething: PSomething);begin  // direct modification of inherited fields  ASomething^.X := 10;  ASomething^.Y := 20;   // modification of non-inherited object fields  ASomething^.A := 50;  ASomething^.B := 100;end; end.
The structure of the code is correct, it compiles without any errors and works properly.

The problem is that the Completion Box window does not suggest inherited content. In this case, it shows only non-inherited content, i.e. fields A and B, while fields X and Y, although access to them is provided (thanks to the protected section), are not listed — see the attachment.

IMO this is a bug because in the DoSomething routine I have the ability to directly access all the inherited protected content, so the Completion Box should also contain all the protected content that the final object inherits. Am I right?

In the second attachment is a test project, you can check it yourself.

Navigation

[0] Message Index

Go to full version