score:7

Accepted answer

At the bytecode level, final doesn't exist for local variables. In fact the concept of local variables itself doesn't really exist either. Marking a local variable as final is purely for compile time checking. Since the information isn't present in the classfile, the decompiler has no way of guessing it.

As for the second two questions, I'm not as familiar with CIL bytecode, but if I had to guess I'd say that there's no reason not to add override, and readonly might have different semantics.

Edit: After looking through the CIL specification, here's what I've found.

The CIL equivalent of Java's final flag for fields is initonly, which appears to have the same semantics. It's not clear why the Scala compiler doesn't emit this. Perhaps they just didn't get around to it? Or perhaps the .net decompiler you used didn't reflect this. If you want to see what the compiler actually generates, you're best off looking at the bytecode directly.


Related Query

More Query from same tag