In another answer here they give the following code example:
scala> implicitly[Int => { def min(i: Int): Any }]
res22: (Int) => AnyRef{def min(i: Int): Any} = <function1>
That doesn’t work in my scala console (2.10.0-RC2).
scala> implicitly[Int => { def min(i: Int): Any }]
<console>:8: error: No implicit view available from Int => AnyRef{def min(i: Int): Any}.
implicitly[Int => { def min(i: Int): Any }]
^
scala> 12 min 11
res15: Int = 11
What is the new way to do it? And what does that syntax mean anyway? I’m not familiar with it — specifically the part { def min(i: Int): Any }, used as a type expression. Is that defining an anonymous type of some kind?
I want to do this because I’d like to track down an implicit conversion when I see it in code and have no idea where it is imported from. For example, the other day I saw some code that was calling format on a java.util.Date, which doesn’t have format. I didn’t know which import pulled in the conversion.
You’re not going to find
minbecauseRichIntis a value class now (which doesn’t work with structural typing–that has to be anAnyRef).But the strategy will work otherwise:
So the same trick will work, just not with value classes. Try an IDE instead.