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

Comments

Projects
None yet
3 participants
@alexnask
Collaborator

alexnask commented Sep 21, 2014

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

This comment has been minimized.

Collaborator

fasterthanlime commented Jul 9, 2015

Ooh, that looks good

screen shot 2015-07-09 at 22 39 33

@vendethiel

This comment has been minimized.

vendethiel commented Jul 9, 2015

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

@fasterthanlime

This comment has been minimized.

Collaborator

fasterthanlime commented Jul 9, 2015

Ehhh now is not the time for such questions.

@fasterthanlime

This comment has been minimized.

Collaborator

fasterthanlime commented Jul 9, 2015

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

@fasterthanlime

This comment has been minimized.

Collaborator

fasterthanlime commented Jul 9, 2015

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

This comment has been minimized.

vendethiel commented Jul 9, 2015

fair enough ;-)

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