Scripting: fix script lowering in case of out of order declarations

The problem was that in K2 for some top-level script declarations we
need to add a dispatch receiver parameter (because frontend do not
assign any, but representing script as a class requires it to be the
script class) and at the same time, calls to these declarations rely on
properly set dispatch receiver parameter.
The simplest solution found is to have an additional traversal on the
relevan top-level declarations and assigning the dispatch receiver,
before running the main transformation.

#KT-64502 fixed
This commit is contained in:
Ilya Chernikov
2024-02-15 12:32:04 +01:00
committed by Space Team
parent 266447120d
commit eab5164993
8 changed files with 102 additions and 2 deletions
@@ -0,0 +1,7 @@
// code from KT-64502
fun foo() {
bar()
}
fun bar() {}