Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rock infers generic type exclusively from the first instance it can #825

Closed
alexnask opened this issue Sep 21, 2014 · 6 comments
Closed

Comments

@alexnask
Copy link
Collaborator

Foo: class { init: func }
Bar: class extends Foo { init: super func }

f: func <T> (a, b: T) {
    T name println()
}

f (Bar new(), Foo new())

This should print Foo but it prints Bar, as T is infered from the first argument it appears in a.
Instead, findCommonRoot should be used here.

@fasterthanlime
Copy link
Collaborator

Ooh, that looks good

screen shot 2015-07-09 at 22 39 33

@vendethiel
Copy link

Just a question... what is the performance impact of such unification with say, an array literal of 500 elements?

@fasterthanlime
Copy link
Collaborator

Ehhh now is not the time for such questions.

@fasterthanlime
Copy link
Collaborator

(But it'd be interesting to make a stress test & optimize from there. Later.)

@fasterthanlime
Copy link
Collaborator

So, there'll probably be about a dozen duplicates of this in the future.. but at least for this case, I have a fix.

I've tried going further but then the sdk starts showing cracks everywhere so uh, better left for another time. At least we're on the path to basic sanity.

@vendethiel
Copy link

fair enough ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants