``` interface Node {} class NodeImpl1: Nod...
# announcements
g
Copy code
interface Node {}
    class NodeImpl1: Node {}
    class NodeImpl2: Node {}

    interface NodeVisitor {
        fun visit(n: NodeImpl1): Unit = TODO();
        fun visit(n: NodeImpl2): Unit = TODO();
    }

    fun <T: Node> T.accept(visitor: NodeVisitor){
        visitor.visit(this)
    }