trait T { fun foo(): Int } trait U: T fun test(t: T): Int { return if (t is U) t.foo() + 1 else t.foo() }