Delegates must be constructor arguments?


It would appear so. Do you think it would be good to allow normal instance variables too?

class Pager(elt: Element) : Element by elt2 {   // by elt is ok, but not by elt2
  private val elt2: Element = buildDiv()



There are issues with allowing that: for example, that property might not have been initialized by the time someone calls a delegated method (from an initializer of another property, for example)


That makes sense.  A related question: should this not compile?

class Bar {
  var s: String

  s = “”

  private fun helper() {

It compiles without warning and throws a NullPointerException.



It would be nice to prohibit things like this (and Ceylon does, for example), but restrictions it imposes are rather severe, so we decided not to make this checks