Avatar
Scala だと :> 使って簡単に lower bound を書けるのかぁ。 class A {} class B extends A {} trait T[-X >: B] { def bar(x: X): Unit } class C extends T[A] { def bar(x: A): Unit = { println("C.bar: " + x) } } val c: C = new C() val t: T[B] = c t.bar(new B())
4:13 PM
C.bar: Playground$B@16418d1a