Scala bashing
Feb. 25th, 2019 08:09 pm1. If in your trait
2. Similar things may happen if you extend a trait e.g.
and then have
and then call
3. The argument type of
The latter is kind of obvious, since, well, what is it. But it makes everything just fake.
And I wonder, is it Scala, is it JVM, or is it Curry Type System?
Fuck, in short.
MyTrait you have val x: String = "This is my string", and refer this x from something that extends MyTrait, you can easily get AbstractMethodError during runtime. If you make it lazy val x..., it'll work. If you make it def x..., it'll work even better.2. Similar things may happen if you extend a trait e.g.
trait MyTrait[C] { val dom: C; def op(x: dom.X): String} and have
class Z[D] extends MyTrait[D] {
override def op(x: dom.X): String { println("hi") }
def doit(z: dom.X) = { op(x) }
}
and then have
val sample = new Z[Int](){ override def op(x: dom.X): String { println("wow") }},and then call
sample.doit(42), you can have either AbstractMethodException or have the op called that is not defined in your instance.3. The argument type of
MyTrait.op(dom.X) is, according to reflection, is java.lang.Object.The latter is kind of obvious, since, well, what is it. But it makes everything just fake.
And I wonder, is it Scala, is it JVM, or is it Curry Type System?
Fuck, in short.