ELENA-LANG / elena-lang

ELENA is a general-purpose language with late binding. It is multi-paradigm, combining features of functional and object-oriented programming. Rich set of tools are provided to deal with message dispatching : multi-methods, message qualifying, generic message handlers, run-time interfaces
https://elena-lang.github.io/
MIT License
233 stars 24 forks source link

Parent multi-method default handler is not invoked by its children #520

Closed arakov closed 3 years ago

arakov commented 3 years ago

Describe the bug The parent default multi method dispatcher should be called if the message is not dispatched for a child

To Reproduce

import extensions;

interface IFoo
{
    abstract foo();
}

A : Object, interface<IFoo>
{
    foo()
    {
        console.printLine("foo")
    }    
}

abstract Base
{
    abstract bar(IFoo f);

    // this method should be invoked to correctly typecast A to IFoo
    bar(o)
        <= bar(cast IFoo(o));
}

B : Base
{
    bar(IFoo f)
    {
        f.foo()
    }
}

public program()
{
    auto a := new A();
    auto b := new B();

    b.bar(a)
}

Expected behavior The interface implementation should be invoked.

arakov commented 3 years ago

Much simpler sample which should work as well:

A;
B;
C;

D
{
    foo(A a)
    {
        console.writeLine("A")
    }

    foo(a)
    {
        console.writeLine("default")
    }
}

E : D
{
    foo(B b)
    {
        console.writeLine("B")
    }    
}

public program()
{
    var c := new C();

    var e := new E();

    e.foo(c) // MethodNotFoundException is raised rather then D default handler
}
arakov commented 3 years ago

done