Check if visibility is public API first, then check if declaration is
annotated with `@PublishedApi`. This is needed because loading
annotations and iterating over them can be slow.
Do not compute IdSignature for descriptor a second time when adding a
new symbol. Instead, pass the calculated signature to the lambda in
declare/declareIfNotExists/referenced, and use it in `reference*`
methods.
Extract duplicated code, remove unused methods and unneeded OptIn.
Also, check original for descriptors only in case the symbol is not
computed yet. Checking it on every access is not needed.
Collecting all outer classes into a hash set and looking up classifiers
in that set for each type of each fake override is noticeably slow.
Instead, check that function types reference any type parameter whose
container is a class; if the function is not local, it means such type
parameter belongs to one of the outer classes.
#KT-42020
It's not that simple because we still need inline functions bodies
and classes fields which aren't present in Lazy IR. To overcome this,
save additional binary info for a cached library and then use it when needed
parameters.
This was causing exceptions with analysis API trying to resolve the
synthetic FirValueParameter because it could not find a KtDeclaration
for it. Using BODY_RESOLVE should be safe; the SAM constructor function
is also on BODY_RESOLVE and the type of the value parameter is known.
When storing mapping from moduleName to module information, ensure
that values from kotlinOptions DSL objects are taken into
consideration.
Fixes #KT-49066
Test: KotlinAndroid70GradleIT.testCustomModuleName
Partially fix KT-46525
Now the code like
```
fun foo(a: () -> Unit) {}
interface A {
fun run()
}
fun main() {
foo {
println()
}
val a = object : A {
override fun run() {
TODO()
}
}
}
```
is being compiled into
```
function foo(a) {
}
function A() {
}
A.$metadata$ = {
simpleName: 'A',
kind: 'interface',
interfaces: []
};
function main() {
foo(main$lambda());
var a = new _no_name_provided_();
}
function main$lambda() {
return function () {
println();
};
}
// TODO
function _no_name_provided_() {
}
_no_name_provided_.$metadata$ = {
kind: 'class',
interfaces: [A]
};
```