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

For example, I saw a Scala expression like this:

objX.methodY

There seems to be no way to see where it came from methodY, this could come from:

(1) class objX, let's call itClassX

(2) superclass objX( ClassX), call itSuperClassX

(3) the class ClassZis ClassZnot related to objX, but there is an implicit conversion from ClassXto ClassZ.

So there methodYcan be three possibilities for a source , does anyone have any ideas on how to determine where it is determined methodY?

In other words, in Scala, how to check the method information (especially the method came from an implicit conversion ) in Runtime?

+4
2

, , . :

objX.getClass().getMethod("methodY").getDeclaringClass();
0

- convertToY(objX).methodY, objX , . ?

0

All Articles