Commit Graph

194 Commits

Author SHA1 Message Date
Ilya Chernikov ec2d6ea5f1 Restore script testing on both backends, fix some tests 2021-12-14 13:39:19 +03:00
Ilya Chernikov 670575696f Remove forced old backend for script compilation, using common default 2021-12-14 13:39:19 +03:00
Ilya Chernikov 6d6de9dd76 Implement tests for script instance capturing in the host tests 2021-12-14 13:39:18 +03:00
Ilya Chernikov 10c5071eda Implement backend error reporting on unsupported script capturing
#KT-30616 fixed
#KT-43995 fixed
#KT-19424 fixed
#KT-49443 fixed
2021-12-14 13:39:17 +03:00
Anastasiya Shadrina 37495bcba0 [FE] Change resolution scheme 2021-12-02 20:23:57 +03:00
Anastasiya Shadrina d923c95671 [FE] Add context receivers to scope 2021-12-02 20:23:22 +03:00
Ilya Muradyan 6917ff7d2a [scripting] Move earlierScripts to the frontend descriptor
^KT-20488 fixed
2021-11-30 09:11:59 +03:00
Mads Ager 6622846bc1 [JVM IR] Do not put destructuring params or underscores in LVT.
Putting them in the local variable table means that the debugger
needs to have special handling for parameters with specific names.
That forces us to generate mangled names for these.

Instead of also implementing the name mangling for FIR, this
change gets rid of the parameters from the LVT instead.
2021-11-02 15:13:14 +03:00
Aleksei.Cherepanov 276fb77155 Fix incremental build after changing Java const used as class property
Report Java static final constant with InlineConstantTracker, used as class property in Kotlin for further registration in JPS

#KT-49177 Fixed
2021-10-20 15:06:19 +03:00
Alexey Subach ca2f37f6eb Add possibility to get location of the script.main.kts file
#KT-48414 fixed
2021-10-11 15:45:57 +02:00
Ilya Muradyan 58831eacca [scripting] Make properties from destructing declarations available with reflection 2021-10-07 18:17:21 +03:00
Vyacheslav Gerasimov ab146bd6d4 Build: Fix deprecated Gradle configurations usages
for migration to Gradle 7+ #KTI-559
2021-09-26 18:28:44 +03:00
Alexander Udalov 5d6ca27c93 JVM IR: introduce CodegenFactory.convertToIr
The steps of psi2ir and JVM backend need to be separated in the API
because in case of cyclic module dependencies (which are allowed in JPS)
psi2ir should be run first on all sources, and then JVM backend on each
module separately. `CodegenFactory.convertToIr` does nothing in the old
backend.

Also, move the ignoreErrors to GenerationState for simplicity.
2021-09-17 17:39:48 +02:00
Alexander Udalov 5df316a129 Minor, rename module backend.jvm:backend.jvm.entrypoint -> backend.jvm.entrypoint 2021-09-14 22:29:13 +02:00
Alexander Udalov eee8b033a6 JVM IR: minimize usages of jvmPhases outside backend.jvm 2021-09-14 22:29:12 +02:00
Dmitriy Novozhilov d46e2dd749 Fix OVERRIDE_DEPRECATION warnings in project code 2021-09-02 15:04:07 +03:00
Ilya Chernikov 4243bafd1d Scripting: implement correct disposal of REPL state on finalization
#KT-47927 fixed
2021-08-24 21:39:38 +03:00
Ilya Chernikov a45e31720c Make state of the default REPL compiler explicit and replaceable
restores proper object hierarchy in case the legacy REPL infrastructure
2021-08-24 21:39:37 +03:00
Ilya Chernikov e60e80f19a Scripting: improve reporting on cyclic dependency
#KT-48177 fixed
the issue is in fact fixed by the previous commit (report error
on duplicated import) by normalizing import path before processing,
but here we're making error reporting nicer for the case.
2021-08-24 21:39:33 +03:00
Hung Nguyen 170184dce4 KT-45777: Refactor RuntimeModuleData to support classpath snapshotting
We are working on a feature in the Kotlin Gradle plugin called
`kotlin.incremental.useClasspathSnapshot` to improve incremental
Kotlin compilation.

In this feature, we need to extract ABI information from a .class file.
If the .class file is a Kotlin class, this info can be found in the
class header data. But if the .class file is a Java class, this info is
not readily available.

The RuntimeModuleData class in the ':core:descriptors.runtime' project
can help with that: It uses reflection to generate `ClassDescriptor`s.

However, reflection requires a full classpath to work correctly, whereas
we want to generate a `ClassDescriptor` directly for each class file
(also, reflection is probably slow).

To address that, this commit refactors RuntimeModuleData so that it can
support a generic Kotlin/JavaClassFinder, which can be based on either
reflection or bytecode analysis. The existing code continues to use
reflection while the new feature will use bytecode analysis (e.g., using
the existing BinaryJavaClass).

Bug: KT-45777
Test: Existing tests should pass (this is a refactoring-only change)
2021-08-10 12:29:44 +03:00
Denis.Zharkov ea5157cadc Change type of KotlinCoreEnvironment::projectEnvironment type 2021-07-23 21:38:45 +03:00
Ilya Chernikov 0cd29adcc7 Get rid of kotlinx-coroutines usage in scripting libs and plugins
the dependency on the coroutines library caused various problems like
KT-30778, or stdlib/runtime version conflicts.
The only function used was `runBlocking`, so this change replaces it
with the internal implementation based on the similar internal thing
from the stdlib.
#KT-30778 fixed
2021-07-19 16:35:36 +03:00
Ilya Chernikov dee0487185 IR: Refactor IrBuiltIns to abstract it from descriptors 2021-07-16 02:24:18 +03:00
Georgy Bronnikov 20b76d4149 JVM_IR: reorganize initialization of JvmGeneratorExtensionsImpl
CachedFields are now created at initialization.
Therefore we need CompilerConfiguration as a constructor parameter.
2021-07-14 21:20:30 +03:00
Alexander Udalov 7a42f603f2 JVM IR: rename mangler implementation classes 2021-07-13 01:54:41 +02:00
Ilya Muradyan 787ce6335c Change nestedClasses logic to accept classes with nested type aliases
#KT-47650 fixed
2021-07-08 21:04:53 +03:00
Ilya Chernikov d365d7c784 Fix IR compilation for empty script
#KT-46646 fixed
2021-05-17 20:15:14 +03:00
Dmitriy Novozhilov e5b7cf23d6 Drop min functions from addToStdlib.kt 2021-05-14 14:30:20 +03:00
Vladimir Dolzhenko 590a8d088d Refine locking to avoid dead lock
#KT-46215 Fixed
2021-04-21 11:01:12 +00:00
Vladimir Dolzhenko 613eda5016 Fix PackageFragmentProvider#isEmpty(FqName) for REPL 2021-04-09 21:06:32 +03:00
Ilya Muradyan d40ada5d07 [REPL] Fix syntax errors analysis and incompleteness detection 2021-03-29 18:36:49 +03:00
Ilya Chernikov bcd7bc5fd7 Fix arguments processing with scriting with old backend by default 2021-03-24 21:26:57 +01:00
Ilya Chernikov 3e458a1efb FIR: Add IncrementalPackagePartsProvider usage in cli...
also refactor IncrementalPackagePartsProvider and parents to simplify
usage
2021-03-24 21:24:18 +01:00
Ilya Muradyan 14d386223b [REPL] Fix unresolved imports caching
Before this fix, if some imports were not resolved during compilation,
this result had been saved in caches, and this import couldn't been
resolved during following compilations even if it was added to the
module dependencies. This commit adds special handling of resolution
caches for the REPL compiler.
2021-03-24 13:35:33 +03:00
Ilya Muradyan ae5fefce51 [REPL] Fix performance problem
Configuration updating was done incorrectly,
and it led to performance degradation.
2021-03-24 13:35:33 +03:00
Ilya Chernikov 7d07010785 Fix handling of lambdas in top-level destructuring declarations 2021-03-11 15:50:32 +01:00
Ilya Chernikov 10567d9a37 [minor] fix scripting test dependencies 2021-03-11 15:50:31 +01:00
Ilya Chernikov ef01411d20 [minor] fix script util tests 2021-03-11 15:50:30 +01:00
Ilya Chernikov 375441832e Implement REPL support in IR scripting 2021-03-11 15:50:30 +01:00
Ilya Chernikov e9da385f7c Implement property for passing argumens to isolated script compiler 2021-03-11 15:50:06 +01:00
Ilya Chernikov 43d7536a28 Protect scripts compilation from passing -Xuse-ir via configuration
as well as other options that require changes in the compilation setup
before compiler options from the configuration could be processed
2021-03-11 15:50:06 +01:00
Ilya Chernikov bac6a7346e Extend GeneratorExtensions with previous script, implemt it for JS REPL
also refactor JS REPL for better compatibility with the generic
REPL/scripting infrastructure
2021-03-11 15:50:01 +01:00
Ilya Chernikov 4c6b5ff0b8 Implement IR backend support in scripting tests, enable for some tests 2021-03-11 15:49:44 +01:00
Alexander Udalov 566f97ae3e JVM IR: remove dependency of 'backend.jvm' on 'psi2ir', 'ir.serialization.jvm'
Add a new module 'backend.jvm.entrypoint' which depends on psi2ir and
contains code that runs psi2ir + JVM IR backend with serialization
implementations.

Hopefully this will allow to compile these modules in parallel and
reduce the build time.
2021-03-05 20:46:33 +01:00
Alexander Udalov addabae8d2 IR: move frontend-dependent code into implementations in psi2ir 2021-02-24 19:07:38 +01:00
Alexander Udalov d991a3e40f IR: simplify initialization cycle of TypeTranslator/ConstantValueGenerator 2021-02-24 19:07:38 +01:00
Alexander Udalov ca5a35b4b3 Move CompilerEnvironment from 'frontend' to 'cli'
This is needed in order to have a single convenient place where to
register frontend services implemented _outside_ of the 'frontend'
module, such as the control flow analysis, extracted to a separate
module in a subsequent commit.
2021-02-24 17:17:03 +01:00
Alexander Udalov dbadd5846a Add test for script flag in kotlin.Metadata
It passes at the moment because the test uses old backend, but the
required behavior is not yet supported in JVM IR, and it'll need to be
fixed.
2021-02-18 12:36:54 +01:00
Ilya Chernikov 79b4b18e25 [minor] fix warnings in the script compiler and tests 2021-02-10 08:32:11 +01:00
Ilya Chernikov ef4fa3381d Pass provided script configuration to refining code
when script compilation configuration refinement
happening during parsing, the updated configuration
passed to the script compiler/REPL compile function
is now used.
#KT-44580 fixed
2021-02-09 15:22:55 +00:00