class A { class B; def foo(b:A#B){} //def foo(b:B){} 后面的a1.foo(b2) 就不能通过编译 } object Main { def main(args: Array[String]): Unit = { val a1 = new A; val b1 = new a1.B; val a2 = new A; val b2 = new a2.B; a1.foo(b2); } }
class A { class B; def foo(b:A#B){} //def foo(b:B){} 后面的a1.foo(b2) 就不能通过编译 } object Main { def main(args: Array[String]): Unit = { val a1 = new A; val b1 = new a1.B; val a2 = new A; val b2 = new a2.B; a1.foo(b2); } }