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
In ScalaMock, I need to create instances of traits/classes that may contain abstract methods. To do this, I need to know the types of those methods. Right now, I'm using the following trick:
That looks like an ingenious exploitation of something that was not meant to be used that way. I do not see why it would not work, though. In general, I believe it's better to create an actual val with the proper type that can serve as prefix type.
Unfortunately, this leaves me with a catch-22 - I can't create an instance of that trait without providing implementations of all of its methods. And I can't implement its methods without knowing their types.
Apparently there is a narrow method that does what I need. It would be helpful if it could be added to the reflection API.
The text was updated successfully, but these errors were encountered:
In ScalaMock, I need to create instances of traits/classes that may contain abstract methods. To do this, I need to know the types of those methods. Right now, I'm using the following trick:
described by Martin as:
Unfortunately, this leaves me with a catch-22 - I can't create an instance of that trait without providing implementations of all of its methods. And I can't implement its methods without knowing their types.
Apparently there is a
narrow
method that does what I need. It would be helpful if it could be added to the reflection API.The text was updated successfully, but these errors were encountered: