@ trait FooFilter { val filterName: String } defined trait FooFilter @ val a = new FooFilter{ override val filterName = this.getClass.getCanonicalName } a: AnyRef with FooFilter = ammonite.$sess.cmd1$$anon$1@3d904e9c @ a.filterName res2: String = null
よく考えると当たり前だけど、traitをnewしたものに対してはnullになっちゃう。
@ class BarFilter extends FooFilter { override val filterName = this.getClass.getCanonicalName } defined class BarFilter @ new BarFilter().filterName res4: String = "ammonite.$sess.cmd3.BarFilter"
これならもちろん値ある。