why no by-name conversion of Nothing type ?

View: New views
1 Messages — Rating Filter:   Alert me  

why no by-name conversion of Nothing type ?

by bord :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i have an in-scope implicit conversion for (=> Nothing) type but the compiler errors instead of applying it.

say i have these

implicit def byNameR2T(v: => R) = new T
implicit def byNameNothing2T(v: => Nothing) = new T

inside an object and then when I import the object to some other code I find that I can have the compiler perform the first conversion implicity but not the second.

in particular I'm trying to have the a view applied so that I can invoke say T.foo method after the conversion.
So
if
class R
then
(new R).foo works as i get the implicit conversion followed by apply of foo
but
say i have def g:Nothing = {throw new Exception}
(g).foo
will give
error: value foo is not a member of Nothing

Now I can understand that applying a conversion of "Nothing" to another type does not make sense,
because the Nothing value is never materialized.
And the Nothing being passed by value in the conversion function does not make sense.
However, a conversion function taking "Nothing" by name ( => Nothing) should be different.
Here the conversion should be applied as for all we know the conversion function may never actually uses the parameter (the by-name Nothing).
But still the compiler errors this.
I am using the 2.7.1final compiler and have not been able to try it on anything later.
LightInTheBox - Buy quality products at wholesale price!