Skip to content

Possible problem with HIDDEN methods overriding EXPORTED methods #406

@raphaelgz

Description

@raphaelgz

If a derived class overrides an EXPORTED method as HIDDEN the base class is not allowed to call that method anymore. Is this behavior expected?

The only information I could find that is possibly related to this is the commit 7463296 (search by HB_VIRTUAL_HIDDEN in that commit) were it appears to want to prevent a HIDDEN method from a base class from becoming EXPORTED or overridden in a derived class.

You can reproduce this behavior with the code below.

#include "hbclass.ch"

CLASS Base
EXPORTED:
    METHOD callPrint()
    METHOD print()
ENDCLASS

METHOD callPrint() CLASS Base
RETURN ::print()

METHOD print() CLASS Base
    ? "From Base"
RETURN Self

CLASS Derived INHERIT Base
HIDDEN:  // if you change this to EXPORTED or even PROTECTED this code works as expected
    METHOD print()
ENDCLASS

METHOD print() CLASS Derived
    ? "From Derived"
RETURN Self

PROCEDURE Main()

    LOCAL o
    
    o := Derived():New()
 
    o:print()       // Fails (expected)
    o:Super:print() // works (expected, prints "From Base")
    o:callPrint()   // Fails (not expected, should it print "From Derived"??)

RETURN

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