Entering a `finally` block can happen from many different places:
through an exception, a jump, or normal exit from the `try` block. When
in the `finally` block, all DFA flows must be merged to have correct
smart casting. However, after the `finally` block, if exiting normally
or because of a jump, the combined flow from within the `finally` block
should not be used, but rather an alternate flow which combines the
correct flows from before the `finally` block.
```
try {
str as String // Potential cast exception
} finally {
str.length // Shouldn`t be resolved
}
str.length // Should be resolved
```
When building DFA flows, track the start of possible alternate flows,
and continue building them until they end. Both of these situations are
now marked on CFGNodes via interfaces.
When building the default DFA flow, and the source node is the end node
of alternate flows, attempt to use the alternate flow with the same edge
label instead of the default flow of the source node.
#KT-56888 Fixed
Preliminary refactor in preparation for the implementation details to
fix KT-56888. This change makes it so alternate data flows can be
created and maintained through CFGNodes. This change was separated and
created first to aid in the code review process.
Jump edge targets are maintained globally within the CFG builder and are
added indiscriminately to `finally` exit nodes. This means that a
`finally` exit node could have a jump edge added which doesn't match how
the `finally` block was entered. Make sure edges are only added to the
exit node if they also exist on the enter node.
#KT-60723 Fixed
Effectively, KtScript currently resolves as a monolith,
so we have problems because some declarations have
their own locks, but some others are not
This change fixed many exceptions
^KT-60728
The API replaces 'KotlinCompilerIde' in the IntelliJ IDEA plugin.
Code moved to Analysis API as its K2 implementation severely depends on
the internal compiler API (FIR).
The API is going to be used in the JVM debugger evaluator, and in
the Bytecode Tool Window.
In this commit, only ordinary Kotlin are supported.
In later commits, there will be also support for 'KtCodeFragment' files,
as well as some test coverage.
Modules are absent in the repository by default, but can be added from
the experimental repository. This a temporal solution for building
compatible compose with the Kotlin master.
KTI-1302
- As mentioned in KT-60570, memory consumption in cached symbol names
providers is caused partially by lots of instances of empty mutable
sets. This commit replaces such sets with the `emptySet()` singleton.
- This improvement also makes sense for callable names because the IDE
"package names with top-level callables" set currently contains all
package names in the project.
- In my local tests of the `setUp` Find Usages performance test, the
retained size of `FirDelegatingCachedSymbolNamesProvider` is cut down
from 208MB to 170MB by the empty class name set optimization, and from
170MB to 115MB by the empty callable name set optimization.