Skip to content

[#165 follow-up] Class-interface-implementation diagnostic — cross-file enumeration + inherited-method resolution + overload discrimination #181

Description

@msarson

Status

Core diagnostic shipped on version-0.9.7 (commit 65dae3d). This issue now tracks the two remaining refinements (items 2 & 3 below).

Model correction (2026-06-07). Earlier versions of this issue — and the original #165 implementation — assumed an implementing CLASS,IMPLEMENTS(Interface) re-declares the interface's methods in its own body. That is wrong. Verified against the Clarion docs (INTERFACE (class behavior definition), Implementing INTERFACEs in Derived Classes) and the shipping LibSrc (C:\Clarion\Clarion11.1\LibSrc\win):

  • The interface's method prototypes live in the INTERFACE structure.
  • The implementing class body holds only its own methods/data — never the interface methods. E.g. CSocketConnection CLASS,...,IMPLEMENTS(IConnection) in abapi.inc lists Construct/Destruct/Init/Kill/..., none of IConnection's methods.
  • The interface methods are implemented as three-part Class.Interface.Method PROCEDURE definitions in the class's MODULE('x.clw') — e.g. CSocketConnection.IConnection.CloseSocket PROCEDURE in abapi.clw.

The old class-body check would have false-positived on every interface implementation in the shipping library. The diagnostic was rebuilt around the correct model.

What shipped (v1, 65dae3d)

Warns when a non-derived CLASS,IMPLEMENTS(Interface) does not provide an implementation for one of the interface's methods.

  • Required methods: resolved from the INTERFACE via the class file's INCLUDE chain (MemberLocatorService.enumerateInterfaceMembers).
  • Provided implementations: three-part Class.Interface.Method MethodImplementation tokens collected from:
    • the class's MODULE('x.clw') (collectImplementedInterfaceMethods), or
    • the current document when the class is declared + implemented inline in a PROGRAM/MEMBER source with no MODULE attribute (collectImplementedInterfaceMethodsFromTokens, gated on getDocumentKind()).
  • Conservative — no false positives: skips derived classes, declaration-only .inc files with no MODULE, and any case where the interface or implementation source can't be resolved.
  • Tests: disk fixture mirroring the LibSrc layout + same-file fixtures, incl. a false-positive guard (fully-implemented class ⇒ no warning).

Remaining scope (this issue)

2. Inherited-implementation resolution for derived classes

v1 skips CLASS(Parent),IMPLEMENTS(...). Per Implementing INTERFACEs in Derived Classes, a derived class may implement only some interface methods — the compiler stubs the rest to jump to the nearest ancestor implementation. To validate derived classes without false positives, walk the parent-class chain (each ancestor's MODULE .clw) and treat an interface method as satisfied if implemented on the class or any ancestor. Many real LibSrc implementers are derived (GridClass CLASS(BrowseClass), SMTPTransport CLASS(TELNETTransport), the FileManager-derived encoders), so this materially widens coverage.

3. Parameter / overload discrimination

v1 matches by method name only. A refinement could compare the three-part implementation's parameter signature against the interface prototype (interface declares Foo(STRING), class implements only Foo(LONG) ⇒ warn), reusing the overload substrate from #125/#127/#128. Higher false-positive risk (signature normalisation), so lower priority.

Cross-references

Priority

Normal — v1 covers the common non-derived case correctly; items 2 & 3 extend coverage and carry more false-positive risk, so they're deliberately deferred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions