lundi 11 mai 2015

In Scala/Java, how to inspect where a method is defined?

For example, I saw a Scala expression like this:

objX.methodY

There seems no way to see where methodY came from, it may came from:

(1) the class of objX, let's call it ClassX

(2) the super class of objX (ClassX), let's call it SuperClassX

(3) a class called ClassZ, ClassZ is irrelevant to objX, but there is an implicit conversion from ClassX to ClassZ.

So there may be three possibilities for the source of methodY, does anyone have ideas about how to find out where the methodY is defined?

In other words, in Scala, how to inspect the information of a method (especially the method came from implicit conversion) at Runtime?





Aucun commentaire:

Enregistrer un commentaire