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 X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...