Do not use tooltip for overloaded method in generic class

I have generic classin my project that has two overloaded methods with different visibility:

  • One with visibility privateand some parameters. It uses parameters and some private structures (some of which are entered in the constructor) to perform some operations.
  • The second, with visibility protected, which is without parameters. This method is used by derived classes to perform operations performed by a superclass. For this he calls the private method.

This works fine, but the compiler displays a hint message as follows:

[dcc32 Hint] Project1.dpr (15): H2219 Private symbol "Bar" declared, but not used

Out of curiosity, I tried to recreate the class without being shared. In this case, the compiler hint does not appear.

Below you can find a simple example demonstrating a case:

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

type

  //class with generic type
  TFoo<T> = class
    private
      procedure Bar(param : string); overload;
    protected
      procedure Bar; overload;
  end;


  //class without generic type
  TFoo2 = class
    private
      procedure Bar(param : string); overload;
    protected
      procedure Bar; overload;
  end;

  //TFoo<T> methods
  procedure TFoo<T>.Bar(param: string);
  begin
    writeln('Foo<T>. this is a private procedure. ' + param);
  end;


  procedure TFoo<T>.Bar;
  begin
    writeln('Foo<T>. This is a protected procedure.');
    Bar('Foo<T>. calling from a protected one.');
  end;

  //TFoo2 methods
  procedure TFoo2.Bar(param: string);
  begin
    writeln('Foo2. this is a private procedure. ' + param);
  end;


  procedure TFoo2.Bar;
  begin
    writeln('Foo2. This is a protected procedure.');
    Bar('Foo2. calling from a protected one.');
  end;


var
  foo : TFoo<string>;
  foo2 : TFoo2;
begin
  try
    foo := TFoo<string>.Create;
    foo2 := TFoo2.Create;
    try
      foo.Bar;
      foo2.Bar;
      readln;
    finally
      foo.Free;
      foo2.Free;
    end;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

In this example, the generic type is not used, but there is no need to show a period. My real class uses it, and a compiler hint also appears.

Any idea as to why this compiler hint appears for generic classes? I tested this on Delphi XE5.

Update : as if it were a compiler error, we sent a QC report .

+4
source share
1 answer

This is a compiler error. You must submit a quality control report.

, Delphi. , XE3. Bar :

[dcc32 Error]: E2250 "Bar",

, .dpr.

+3

Source: https://habr.com/ru/post/1534630/