H2440 Inline method visibility is not lower or same visibility of accessing member '%s.%s' (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

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.