Differ this/non-this instances for vars initialization in class

When deal with constructed object (not this) treat it like it's fully initialized.

Otherwise (this or access with no receiver) access instruction
should be handled as it was before.

 #KT-6788 Fixed
 #KT-4126 Fixed
This commit is contained in:
Denis Zharkov
2015-02-17 10:23:07 +03:00
parent 1004e016fd
commit 7d963e8e07
17 changed files with 300 additions and 50 deletions
@@ -0,0 +1,21 @@
class Outer {
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val outerProp: String<!>
inner class Inner(inner: Inner, outer: Outer) {
val innerProp: String
init {
outerProp // use of outerProp is ok because we're suppose that Outer instance should be initialized
this@Outer.outerProp
<!VAL_REASSIGNMENT!>this@Outer.outerProp<!> = "1"
outerProp = "2" // do not repeat the same diagnostic with this receiver of outer class
<!VAL_REASSIGNMENT!>outer.outerProp<!> = "3"
innerProp = "4" + inner.innerProp
<!VAL_REASSIGNMENT!>this@Inner.innerProp<!> = "5"
innerProp = "6" // do not repeat the same diagnostic with this receiver
this@Inner.innerProp = "7"
<!VAL_REASSIGNMENT!>inner.innerProp<!> = "8"
}
}
}