FIR: Report CAPTURED_VAL_INITIALIZATION if initialization is done

outside of constructor.

In other words, when EXACTLY_ONCE lambda initializes non-static final
field of a class, the lambda has to be inlined, otherwise, backend
generated separate function of separate class for the lambda,
which lead to exception at runtime.

 #KT-64854 Fixed
 #KT-59906 Fixed
This commit is contained in:
Ilmir Usmanov
2024-03-05 22:00:19 +01:00
committed by Space Team
parent 5dec87eba8
commit 1c4023fda5
7 changed files with 149 additions and 10 deletions
@@ -86,7 +86,7 @@ class DefiniteInitializationInInitSection {
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val y: Int<!>
init {
myRun { x = 42 }
myRun { <!CAPTURED_VAL_INITIALIZATION!>x<!> = 42 }
unknownRun { <!CAPTURED_MEMBER_VAL_INITIALIZATION!>y<!> = 239 }
}
}