RichInt と構造的部分型で Runtime Error
type LT = { def < (that: Int): Boolean } def lt(x: LT, y: Int): Boolean = { println(a.getClass) x < y }
scala> lt(2,3) class scala.runtime.RichInt java.lang.NoSuchMethodException at scala.runtime.BoxesRunTime.testLessThan(Unknown Source) scala> lt(new scala.runtime.RichInt(2), 3) class scala.runtime.RichInt java.lang.NoSuchMethodException at scala.runtime.BoxesRunTime.testLessThan(Unknown Source)
こういうのは implicit parameter で Ordered[Int] を取るのが正しいのかもしれないけど、これはいったい何故ランタイムエラーになるのかなあ・・・。