Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note
The AL diagnostics topics are in preview. If you have input for this topic, we'd love to hear from you. Use our GitHub repo to create a PR and add content to this topic by going to here. To read about contributing, see Contribute to the Help. Thanks!
The method '{0}' cannot be used as the implementation for the interface method '{1}' because it is not public.
Description
Interface implementations must be publicly accessible because interfaces can be invoked across module boundaries. Non-public methods will not be dispatched correctly at runtime.
Remarks
Interface methods are called through an interface variable, which can be passed across module boundaries. The implementing method must be public so that the runtime can dispatch the call correctly. This error is the enforcement version of warning AL0920, which was introduced in an earlier runtime version.
How to fix it
Change the accessibility of the implementing method to public by removing the local or internal access modifier.
Example of code that triggers AL0921
interface IValidator
{
procedure Validate(input: Text): Boolean;
}
codeunit 50100 MyValidator implements IValidator
{
// Error: internal method cannot implement an interface method.
internal procedure Validate(input: Text): Boolean;
begin
exit(input <> '');
end;
}
Example of how to fix it
Make the implementing method public.
interface IValidator
{
procedure Validate(input: Text): Boolean;
}
codeunit 50100 MyValidator implements IValidator
{
procedure Validate(input: Text): Boolean;
begin
exit(input <> '');
end;
}
Related information
Getting started with AL
Developing extensions
Interfaces in AL
Compiler Warning AL0920