object A { class B fun foo() = 1 object Bar{} } fun test(a: T) { val c = (a as A) c.B() }