Optimization: often we don't need all hashes for all available symbols.
This patch allows the calculation of the symbol hash only on demand.
This patch also allows cycles for the inline function dependency
graph in the IC infrastructure. Note that the inline function cycles
may crash the inliner, however it is not the IC infrastructure
responsibility to check the cycles.
If inline function A calls another inline function B,
we must use the original version of inline function A for inlining,
which doesn’t have inlined function B. Because during the inlining
process, we remap all occurrences of inline function A
to a temporary copy of function A, and if the function B
somehow uses function A (e.g. callable reference),
the built IR will have a reference to the temporary function,
not the original one. All these things lead to broken cross-module references.
This patch saves the original versions of all inline functions
before inlining and provides them during the inline process.
^KT-55930 Fixed
We do not need to check a default implementation of the interface during
the translation to JS because it must be checked before.
Moreover, this check breaks the produced JS code
if IR is partial loaded, e.g. during the incremental rebuild.
^KT-55716 Fixed
The JsAllowValueClassesInExternals feature is enabled explicitly,
because otherwise it's enabled
implicitly depending on the backend. See:
org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt:90
A property may have a fake source return kind, while its accessor
has a real source kind. In this case we can't "just copy"
the property return type down to the accessor.
This feature is not needed because it is unconditionally disabled for K1
(because of not fully correct implementation) and unconditionally enabled
in K2 (K2 does not support old behavior)
^KT-38895
Generally, the library order doesn't matter.
However, after lowering we need to post process
lowered klibs in topological order:
- commit incremental cache artifacts,
- produce JS AST.
The patch uses an ability of the Kotlin library resolver to load klibs
in topological order and drops its reimplementation from IC infrastructure.
There is one side effect:
klibs which are not reachable from the main module, will produce their JS.
This should be more correct than just ignoring them.
A suspend stub for the abstract function
may be created in the context of the child function.
If on an incremental rebuild the stub is created from
the parent context (e.g. a file with the child is not modified),
the resulting LoweredDeclarationSignature will be different.
It will lead to a broken cross-module reference and broken JS code.
Therefore it is required to wrap the creation routine
into StageController::restrictTo() explicitly.
^KT-54934 Fixed
We will need it to generate original names for catch parameters in
sourcemaps.
Also, don't generate redundant debug info for compiler-generated
exception handling control flow operators.
See the doc comment to the MultipleCatchesLowering class
#KT-46276