Skip to content

Pre-release of the AL compiler: AL0920 reports warnings on internal interfaces #8279

Description

@bjarkihall

1. Describe the bug
We're getting reports in the pre-release of AL of the new/undocumented AL0920 warning.

The method 'Foo' cannot be used as the implementation for the interface method 'IFoo.Foo' because it is not public. This warning will become an error when targeting a runtime with version '19.0' or higher.

Interfaces can be declared as public or internal on object-level, e.g. for mocking/testing.
Interface methods themselves cannot be declared as internal.
A codeunit implementing the interface can be declared public or internal on object-level, and its procedures can be local/internal/public.

2. To Reproduce
Declare an internal interface and implement it using internal procedures for the signature and you'll get the warning (future error).

interface IFoo {
    Access = Internal;
    procedure Foo() // interface procedures can't be explicitly marked as internal, but the object itself is internal
}

codeunit 50000 CuFoo implements IFoo {
    internal procedure Foo() // matches the signature and access of IFoo.Foo
    begin
    end;
}

3. Expected behavior
We expect the warning not to apply to interfaces with Access = Internal, because their procedures aren't publicly available.
CuFoo.Foo isn't public, but so is IFoo.Foo, because IFoo isn't public.

4. Actual behavior
A warning is raised, indicating it'll be a future error.

5. Versions:

  • AL Language: 18.0.2498801
  • Visual Studio Code: 1.125.1
  • Business Central: 28.0 , runtime 17.0
  • List of Visual Studio Code extensions that you have installed: Pre-release of ms-dynamics-smb.al
  • Operating System:
    • Windows
    • Linux
    • MacOS

Final Checklist

Please remember to do the following:

  • Search the issue repository to ensure you are reporting a new issue

  • Reproduce the issue after disabling all extensions except the AL Language extension

  • Simplify your code around the issue to better isolate the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions