1. if an argument of a `pop` cannot be removed, then all other potential
arguments of that `pop` can't be removed either, and the same applies
to other `pop`s that touch them;
2. the same is true for primitive conversions, but this is even trickier
to implement correctly, so I simply did the same thing as with
boxing operators: replace the conversion itself with a `pop` and keep
the argument as-is.
Somehow this actually removes *more* redundant primitive type conversions
than the old code in a couple bytecode text tests, so I've patched them
to kind of use the value, forcing the instructions to stay.
#KT-46921 Fixed
CoroutineTransformermethodVisitor attempts to extend the ranges
of local variables in various situations. Probably in an attempt
to give a better debugging experience. However, all of these
range extensions lead to invalid local variable tables where
something is in the local variable table where nothing is in the
corresponding slot.
The code that extends variables to the next suspension point
instead of ending them when they are no longer live has issues
with loops. When resuming and reentering the loop, the locals
table will mention a local that we did not spill and which
is therefore not restored when resuming.
The code that extends local variable table entries if there
are no suspension points between two entries doesn't work
for code such as:
```
var s: String
if (suspendHere() == "OK") {
s = "OK"
} else {
s = "FAIL"
}
```
If the local variable ranges are collapsed into one, one of
the branches will have the local defined in the local variable
table before the slot is initialized.
Before this commit, FIR mangler effectively dropped f/o parameter with
invisible type from this module. It could lead to signature clashes.
Now we insert classId in mangler string instead.
This fixes FIR bootstrap.
This is not an ideal fix of the problem since the fact that
AbbreviatedType's classifier should be a TypeAliasDescriptor is a
reasonable assumption that might fail somewhere else, later in the
pipeline.
Previous attempts to fix this issue that were unsuccessful:
1) Do not load abbreviations for such types in deserialization at all.
Unfortunately, it broke quite a few things like reflection and
decompiler, where types frequently refer to symbols not reachable
from the point where they're requested, yet we have the FQ name of
the typealias, which is enough to render the abbreviation properly in
both these use cases.
2) Load classifiers for unresolved abbreviations as
MockTypeAliasDescriptor instead of MockClassDescriptor in
NotFoundClasses. Technically this was a revert of
e19c1b5364. But this failed because we
don't have enough information about such typealias to correctly set
its `expandedType`/`underlyingType` (just using nullable Any as
before that commit is not good enough). We only know its underlying
class (from one usage of such typealias), and even supporting that
would involve a major refactoring of TypeDeserializer which is
painful.
#KT-45308 Fixed
They started failing once we began reporting diagnostics from completion
The main reason is that we resolve `delegate()` call
from `delegate().getValue()` in the independent context, while in FE 1.0
it's being resolved within the same system as getValue
^KT-46420 Relates
Prefer to have all module dependencies, including dependencies on
stdlib/reflect, declared explicitly. This allows to have tests on
situations like the one in KT-45308: three modules A<-B<-C, where C
doesn't depend on A, which was compiling correctly with the old JVM
backend before 1.5, but started to fail with JVM IR in 1.5.
Also simplify the code a bit, remove duplicated logic.
Old compiler versions still won't be able to load default lambdas
generated by JVM_IR, but this way we avoid incorrect behavior of
function references taking inline class types that unbox to Any.
#KT-46601 Fixed
Special getter names (like Collection.size()) can be used only in Java
classes with all-java super-types
Because if there is a kotlin class (not interface) in
the middle, we 'materialize' special getters to properties.
This will be used at least in the JVM backend instead of the current
approach where we're loading the primary constructor's first parameter,
which isn't good enough since primary constructor can be private, and
we can't rely on private declarations in case they're declared in
another module.