FIR: only allow member val initialization through this@T

class C {
    val x: Int
    init {
      // valid ways to initialize:
      x = 1
      this@C.x = 1
      // invalid:
      someOtherC.x = 1
      run { /*this@run.*/x = 1 }
      val self = this
      self.x = 1
    }
  }
This commit is contained in:
pyos
2023-01-19 10:57:34 +01:00
committed by teamcity
parent 123b211fc4
commit c42dd0848e
9 changed files with 57 additions and 45 deletions
@@ -1,7 +1,7 @@
class A(val next: A? = null) {
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val x: String<!>
init {
next?.x = "a"
next?.<!VAL_REASSIGNMENT!>x<!> = "a"
}
}