Is it possible for a method to know the type of the method it is called under? So for example in the following object orientated psuedo code: Instance io = new InstanceSubclass();io.doStuff();Is there a language that allows doStuff() to know that it was called as an Instance?The question arose out of the fact the Java does not provide any kind of support for interface name clashes, for example if you create a class that implements interfaces A and B that both have a method signature such as void doWork() would it be possible for the body of doWork() to do something similar to the following :public void doWork() {    Class<?> context = getMethodCallContext();    if(context == InterfaceA.class) {        doAsInterfaceA();    }    else if(context == InterfaceB.class) {        doAsInterfaceB();    }    else {        // Shenanigans and error handling    }}I am not planning to write any code that takes advantage of this feature as to do so reeks of an anti-pattern waiting to happen, I only want to know if it CAN be done, if so which languages permit it?
Are there any languages that allow the static context of a method call to be available at runtime?
object oriented;philosophy;static typing;high level;runtime
In C# you just do: void InterfaceA.doWork() { } void InterfaceB.doWork() { }So there are no real shenanigans involved.The calling function needs to identify which doWork() is intended:Instance io = new InstanceSubclass();((InterfaceA)io).doStuff();See this page for more details.