You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure whether this is an intended behaviour? But it doesn't feel right since it shouldn't matter to the developer the order of class and its companion object.
Note that these also happens for traits.
The text was updated successfully, but these errors were encountered:
Shiva Wu (shivawu) said:
Yeah, these two issues do look similar.
But I think they're a bit different in the sense that, in #8697, it's two objects.
but In this issue, it turns out to be the trait and its companion object.
I kind of get the impression that the trait should be defined before its companion object, at least in usual scala code style.
But if this issue exists, it violates this code style.
Moreover, in this issue and in #8697, the implicit can not be found even after it has been imported into the scope.
This is kind of a bummer.
If I define a typeclass in a class's companion object and use it in the class, like this:
The following compilation error is fired:
error: could not find implicit value for parameter e: Util.Read[Int]
val reading = implicitly[Read[Int]].read("100")
But if the object is defined before the class, it works OK.
I'm not sure whether this is an intended behaviour? But it doesn't feel right since it shouldn't matter to the developer the order of class and its companion object.
Note that these also happens for traits.
The text was updated successfully, but these errors were encountered: