original.name="MethodRef_Valid_6" ====== >>> main.whiley type Event is &{ int timestamp, ... } type Node is &{ // Arbitrary data field int data, // The event listener method listener(Event), // Setter for field method setListener(method(Event)) } method defaultListener(Event e): skip method defaultSetListener(method(Event) e): skip method mutatingListener(Node n, Event e): n->data = e->timestamp method setListener(Node self, method(Event) listener): self->listener = listener // object constructor method Node() -> Node: Node n = new { data: 0, listener: &defaultListener, setListener: &defaultSetListener } // Bind correct listener n->setListener = &(method(Event) fn -> setListener(n,fn)) // return n public export method test(): Node obj = Node() // Check status quo assume obj->listener == &defaultListener assume obj->data == 0 // Update listener from default obj->setListener(&(Event e -> mutatingListener(obj,e))) // Fire the listener obj->listener(new {timestamp: 123}) // Check whether stuff changed assume obj->data == 123 ---