Commit Graph

58 Commits

Author SHA1 Message Date
vladislav.grechko 34bac48541 Add JVM ABI K1/K2 consistency tests 2023-12-26 10:18:19 +00:00
Ilya Chernikov 31f9e9e7a8 K2 Scripting: implement basic metadata serialization support
#KT-62305 fixed
NB: kotlin reflection do not see script class constructor after
this change, and it's ok, since the fact that the script is compiled
into a class is an implementation detail.
If needed, java reflection could be used to access the constructor.
2023-11-03 21:54:23 +00:00
Dmitriy Novozhilov 3b6ad36af1 [Test] Update/unmute tests after previous fixes
It's hard to tell which exact commit fixed each test
2023-10-17 12:46:28 +00:00
Ilya Chernikov 1d88c307ea K2 Scripting: fix locality of script declarations
the script declarations are considered public, at least because they
can be reused from another script then used with the `importedScripts`
configuration property. It also improves the compatibility with K1
scripting.
2023-07-26 08:49:27 +00:00
Ilya Chernikov 5e3f7184d1 IR Scripting: fix capturing of the script parameter in a fun 2023-07-05 19:46:04 +00:00
Ilya Chernikov bf3a6f7678 K2 Scripting: support script top-level destructuring declarations 2023-07-05 19:46:04 +00:00
Ilya Chernikov 02e2438d37 K2 Scripting: fix script this receiver handling in IR
also fix accessor lowering
2023-07-05 19:46:04 +00:00
Ilya Chernikov 07df03dbec K2 Scripting: fix capturing in scripts created from Fir 2023-07-05 19:46:04 +00:00
Ilya Chernikov 1a735b0842 K2 scripting: support script-level typealiases 2023-07-05 19:46:04 +00:00
Ilya Chernikov 7484ccb9ee K2 Scripting: allow script top level inline functions 2023-07-05 19:46:03 +00:00
Ilya Chernikov f79f715590 Fir2Ir: remove error reporting on no receiver
this error is not valid for scripts, where some receivers are set
later in the lowering, and it looks like in other cases this problem
will be detected later in lowering or codegen anyway.
2023-07-05 19:46:03 +00:00
Ilya Chernikov 7866c63e49 Fir2Ir: add fake overrides binding for script top level classes 2023-07-05 19:46:03 +00:00
Ilya Chernikov 9adf24950a Fir2Ir scripts: fix declarations registration and processing 2023-07-05 19:46:03 +00:00
Ilya Chernikov 5824b9c59c K2 Scripting: add Fir script codegen tests
27 failing tests are muted
2023-07-05 19:46:03 +00:00
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00
Nikolay Lunyak a9343aeb7d [FIR] KT-55840: Ensure everything actually works
This inconsistency is present due to not using the `// WITH_STDLIB`
in the above tests. When K1 creates the enum, it tries to generate
`entries()`, and for that it tries to load `kotlin.enums.EnumEntries`,
but this is actually an unresolved reference. K1 silently swallows it,
and proceeds.

The reason K2 doesn't fail is that in order to generate `entries()` it
simply creates the necessary `ConeClassLikeType` with the desired
`classId` instead of loading the whole `ClassDescriptor`.

The reason we can still observe `$ENTRIES` and `$entries` in K1
is because they are generated during the JVM codegen, and it
only checks if the `EnumEntries` language feature is supported. It
doesn't check if the `entries` property has really existed in IR
(by this time it's expected to have already been lowered to the
`get-entries` function - that's why "has ... existed").

The reason why the codegen doesn't fail when working with
`kotlin.enums.EnumEntries` is because it creates its
own `IrClassSymbol`.

^KT-55840 Fixed

Merge-request: KT-MR-8727
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-10 16:57:51 +00:00
Alexander Udalov 3ab2b82878 JVM IR: script is a valid container for local delegated properties
When serializing metadata for local delegated properties, we need to
find a valid container class where to put it, and where kotlin-reflect
will be able to find that metadata at runtime. Taking just the closest
class lexically doesn't work, because in the attached test, it is a
class for a lambda which does not have metadata and thus does not have a
way to store any extra information.

So, in 1663619606 we started to look for the closest "non-synthetic"
class to store this metadata. But apparently it was missed that script
is a valid container class. In the test, this meant that no
non-synthetic container classes were found to store the metadata, so we
falled back to using the closest class anyway (see `?: this` in
`rememberLocalProperty`), which turned out to be the lambda.

After this change, metadata for local delegated property in a lambda
will be stored in the script class, just like it's stored in the file
class in the non-script case.

 #KT-55065 Fixed
2022-12-01 12:55:01 +01:00
Ilya Chernikov c1c94778ce Detect and report inner classes capturing script instance 2021-12-14 13:39:22 +03:00
Ilya Chernikov cb5e451e05 Implement script instance capturing in script lowering
for regular classes only. Reimplementing the main behavior of the
old BE and implementing few cases on top of it.
#KT-19423 fixed
2021-12-14 13:39:17 +03:00
Ilya Chernikov fd2929d2c5 IR: skip script inner classes in LDL
#KT-49012 fixed
2021-10-01 09:01:36 +02:00
Ilya Chernikov e7cbc9a0fb IR: Process script with LDL as if it is a function body
#KT-46645 fixed
#KT-48025 fixed
2021-08-23 12:49:43 +03:00
Ilya Chernikov 7d07010785 Fix handling of lambdas in top-level destructuring declarations 2021-03-11 15:50:32 +01:00
Ilya Chernikov 60246f2261 Ignore temporarily the kt22029.kts codegen test for JVM IR:
since it fails and I cannot fix it right now.
2020-10-30 12:57:42 +01:00
Dmitry Petrov 5ffd6a737e Closures in scripts have outer expression
#KT-22029 Fixed Target versions 1.2.30
2018-01-10 14:08:56 +03:00
Mikhael Bogdanov a79c2bf999 Write script descriptor type to ASM_TYPE slice
#KT-20707 Fixed
2017-10-10 17:01:23 +02:00
Dmitry Petrov efb6756cbc Initialize property metadata array before class body generation
Initialization of companion object members (e.g., delegate properties
using provideDelegate convention) can depend on property metadata array,
which in turn can be initialized before other class members.

 #KT-18902 Fixed Target versions 1.1.5
2017-07-12 09:37:16 +03:00
Mikhail Zarechenskiy d0e26c6527 Support underscores in non local destructuring declarations 2017-05-25 16:46:06 +03:00
Mikhail Zarechenskiy 47f2386212 Generate non-local destructuring declarations as properties
#KT-5620 Fixed
 #KT-15810 Fixed
2017-05-25 16:46:05 +03:00
Dmitry Petrov 7600b6de52 Allow top-level type aliases in scripts 2017-05-24 11:20:22 +03:00
Dmitry Petrov a974ed1049 Support custom accessors for top-level properties in scripts. 2017-01-26 10:12:13 +03:00
Mikhail Zarechenskiy 7739677a06 Adapt ScriptCodegenTests to last changes
Get rid of possibility to configure script definition without template
class, therefore all tests now are using default script argument
2016-09-20 16:23:41 +03:00
Michael Bogdanov 6b8e8cee17 Fix for KT-12891: Allow to omit type in local delegated property declaration
#KT-12891 Fixed
2016-07-05 21:22:48 +03:00
Mikhael Bogdanov c06b51c1d1 Allow top-level local delegated properties in scripts 2016-05-13 19:11:23 +03:00
Dotlin 4c223845b6 Delegated Properties: Code generation for local properties (JVM) 2016-05-13 19:11:19 +03:00
Pavel V. Talanov bdc64f322c Add script codegen tests with package statements
Tests codegen annotating visitor
2015-11-19 22:57:03 +03:00
Pavel V. Talanov ad58617753 Script refactoring, codegen tests: change test data according to semantics change
Add some new tests for uncovered cases
2015-11-19 22:57:01 +03:00
Denis Zharkov 9dada595b6 Replace deprecated annotations with modifiers in testData 2015-09-18 10:14:41 +03:00
Michael Bogdanov 5cb9671803 Support inlining in scripts and outer expression capturing
#KT-7744 Fixed
2015-05-18 14:47:57 +03:00
Alexander Udalov 415fe7a5e6 Initial support for classes in scripts and REPL 2014-08-13 15:13:22 +04:00
Alexander Udalov 9ae95c1e5c Generate codegen tests on scripts 2014-08-13 15:13:17 +04:00
Andrey Breslav f81bf5ea73 Do not add functions and properties with inferred types as script class memebrs 2014-04-01 12:25:31 +04:00
Ilya Ryzhenkov 98c54f39bb Unify script file extensions to "kts" so that IDEA, compiler and tests agree when to parse as SCRIPT.
Include kt* files into formatter test generation, to test scripting formatting
2014-03-24 18:17:50 +04:00
Alexander Udalov f7b6457139 Replace "jet" package name with "kotlin" in testData 2014-03-02 19:55:26 +04:00
Svetlana Isakova ea611cb51d check modifiers for local declarations 2012-08-22 20:42:35 +04:00
Alex Tkachman b52b92cd31 one more test for scripts 2012-08-02 09:31:32 +03:00
Alex Tkachman 29054586d3 default imports added to script definitions 2012-08-01 23:05:56 +03:00
Alex Tkachman e134969896 making script classes useful/accessable for the rest of the world 2012-08-01 09:58:01 +03:00
Alex Tkachman a98cd7aa0f script renamed 2012-07-30 13:24:59 +03:00
Alex Tkachman 7c2d394412 properr names for scripts 2012-07-29 23:58:45 +03:00
Alex Tkachman f8391619a5 configurable script languages 2012-07-29 21:32:53 +03:00