On 1 Feb 2017 12:27 a.m., "Christoph M. Becker" <[email protected]> wrote:
On 31.01.2017 at 21:47, Levi Morrison wrote:
>> Is there anything else that I am missing?
>
> Sadly, yes. Consider the following snippet:
>
> class A {
> function method(): B;
> }
>
> class B extends A {
> function method(): C;
> }
>
> class C extends B {}
>
> When checking that B::method satisfies the requirements of A::method
> it must know if C extends B. At the time we check if B::method
> satisfies A::method, C will *not* yet be in the symbol table.
>
> You need to adjust the passes over the code to register symbols and
> their declared relationships, and then in a separate pass validate
> them. After that if the class isn't found then you trigger an
> autoload.
>
> It's doable, it just hasn't been done.
An alternative *might* be forward class declarations:
class B extends A;
class C extends B;
class A {
function method(): B;
}
class B extends A {
function method(): C;
}
class C extends B {}
I haven't really thought about the feasibility – just throwing in a
rough idea.
That's simply dumping a language problem onto the user though...