Get distribution and home path in the test to simplify gradle build.
Using NativeCompilerDownloader in the build led to the undesired results
where test get old K/N compiler from the bootstrap, also blocking K/N
version class development.
Before this change all paths to all libraries were hardcoded to
`dist/kotlinc/lib/...`, which is not suitable for usages of test
framework outside of Kotlin project
This is needed to unbound CompilerConfigurationProvider from ApplicationEnvironmentDisposer,
which depends on classes from JUnit 5. This will allow to safely use
compiler test framework with base test framework different from JUnit 5
Fake overrides don't have a signature and can't be assiciated with klib index,
therefore they can't be tracked with incremental cache invalidation logic.
Should be fixed after KT-51896.
Previous code didn't work for kotlin-stdlib-wasm because sources from
other gradle projects are included.
`$rootDir/libraries/stdlib/native-wasm/src/*` sources
were present in files.knf as absolute paths. Now they are truncated
as libraries/stdlib/native-wasm/src/*. For example:
libraries/stdlib/native-wasm/src/kotlin/collections/Collections.kt
Should be removed after fixing KT-50876
KTI-729
As absolute paths were also revealed in
atomicfu.jar
kotlin-stdlib-wasm
kotlin-test-wasm
Use solution from Alexander Likhachev (avoid accessing
buildDir, projectDir in doFirst()) to prevent breaking the configuration
cache.
Should be removed after fixing KT-50876
KTI-729
If a lambda expression does not capture any local variables, convert
it to a global free function and replace the lambda creation with
a reference to that function.
Example: for the following Kotlin code
```kotlin
fun foo(f: () -> Unit) = f()
fun bar() = foo { console.log("hello") }
```
before this patch, we generated:
```js
function foo(f) {
return f();
}
function bar() {
return foo(bar$lambda());
}
function bar$lambda() {
return function () {
console.log('hello');
};
}
```
after this patch, we generate:
```js
function foo(f) {
return f();
}
function bar() {
return foo(bar$lambda);
}
function bar$lambda() {
console.log('hello');
}
```