Delphi Error – H2440 Inline method visibility is not lower or same visibility of accessing member ‘%s.%s’

Delphi Compiler Error

H2440 Inline method visibility is not lower or same visibility of accessing member ‘%s.%s’

Reason for the Error & Solution

A member that is accessed within the body of an inline method must be accessible anywhere that the inline method is called. Therefore, the member must be at least as visible as the inline method.

Here is an example of code that will raise this error:

type
   TFoo = class
   private
     PrivateMember: Integer;
   public
     function PublicFunc:Integer; inline;
   end;

function TFoo.PublicFunc:Integer;
	begin
		Result := Self.PrivateMember;
	end;

Because Result := Self.PrivateMember; will be inserted wherever PublicFunc is called, PrivateMember must be accessible in any such location.

To correct this error, remove the inline directive or adjust the visibility of the inline method or the member it accesses.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...