ooc-lang / rock

:ocean: self-hosted ooc compiler that generates c99
http://ooc-lang.org/
MIT License
401 stars 40 forks source link

When passing a cover template this to a cover template static function, rock doesn't look for the signature in the instantiated cover but in the general one #962

Closed alexnask closed 8 years ago

alexnask commented 8 years ago

This is the best title I could come up with.
Basically, this:

Foo: cover template <T> {
    val: T

    init: func@ (=val)

    bar: func -> Bar<T> {
        Bar<T> new(this&)
    }
}

Bar: cover template <T> {
    ref: Foo<T>*

    init: func@ (=ref)
}

foo := Foo<Int> new(42)

Results in those errors:

dev\test.ooc:7:16 error No such function new(__Foo__Int*) for `__Bar__TClass`

        Bar<T> new(this&)
               ~~~

dev\test.ooc:14:5 info Nearest match is `static __Bar__T new(=ref) -> __Bar__T`
..but the arg `this&` should be of type `Foo<T>*` instead of `__Foo__Int*`

    init: func@ (=ref)
    ~~~~

[FAIL]
alexnask commented 8 years ago

It appears to me rock is looking into the BarT metaclass instead of the BarInt metaclass.
This baffles me because the call is Bar new and T has already been resolved to Int, so it should be replaced with BarInt new or something similar.

alexnask commented 8 years ago

Also, my SafeArray (+ SafeArrayRange + ArrayList) implementation doesn't work because of this :(

alexnask commented 8 years ago

This works fine when passing a T to the other class, by the way.

vendethiel commented 8 years ago

Reading rock issue titles is always such a ride :D

alexnask commented 8 years ago

I couldn't describe it in less words, I am afraid :P

alexnask commented 8 years ago

__Foo__Int (ref: ClassDecl __Foo__Int) vs Foo<T> (ref: ClassDecl __Foo__Int) = -100000

This is one of those things that makes me sad :(

alexnask commented 8 years ago

Probably because of the typeArgs.