556 Commits

Author SHA1 Message Date
Ilya Chernikov fecc5ba501 K2: do not try to resolve invoke on error receiver
If a potential receiver is resolved to an error type, we consider
any other type as a subtype of it and therefore may select
any candidate that we happen to find in a scope.
In particular, in the case of scripts, or code with a context receiver,
the receiver candidate resolved to a cycle was accepted as a receiver
to an invoke on a random class from stdlib.
The fix skips adding invoke resolve task in this case, allowing
the tower to find the correct candidate in another scope.

#KT-64241 fixed
#KT-65576 fixed
2024-03-19 15:38:35 +00:00
Ilya Chernikov d5ad41fa28 K2 Scripting: add failing test for #KT-64241 2024-03-19 15:38:35 +00:00
Ilya Chernikov 60e38d592c Tests, Scripting: extend custom def test infra with gradle-like def
to be able to test gradle-like DSL
2024-03-19 15:38:34 +00:00
Mikhail Glukhikh 8ac576614f Revert "Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551)"
This reverts commit 893e5cac
2024-03-15 11:33:10 +00:00
Christian Melchior 4464385fa9 Scripting: KT-62576 Remove irrelevant output from classpath debug information.
Merge-request: KT-MR-14868
Merged-by: Christian Melchior <christian.melchior@jetbrains.com>
2024-03-14 20:52:27 +00:00
Mikhail Glukhikh 893e5cac94 Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551) 2024-03-13 20:38:44 +00:00
Ilya Chernikov 0fe793943d K2, REPL: Display a warning that LV 1.9 is used for REPL in K2
#KT-64384 fixed
2024-03-12 15:57:00 +00:00
Dmitriy Novozhilov d352cc9d96 [Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
2024-03-12 06:43:58 +00:00
Ivan Kylchik c07781326b [K2] Remove performanceManager from CompilationContext 2024-03-08 15:58:33 +00:00
Dmitrii Gridin d5cfea330b [LL FIR] support parameters resolution
Script parameters now can be resolved independently of the script.
But, as parameters are part of the script, their resolve will be called
before the script.

^KT-66276 Fixed
2024-03-07 12:50:59 +00:00
Dmitrii Gridin 150af66b55 [LL FIR] implement diagnostic tests on custom script definitions
it is impossible to declare test data with another output yet
as `myScriptFile.test.ll.kts` won't be treated as custom definition as
it requires `test.kts` extension.

^KT-66232 Fixed
^KT-66276
2024-03-07 12:50:59 +00:00
Yan Zhulanow 4cbd431d22 [Pill] Enable Pill for scripting tests 2024-03-07 06:25:00 +00:00
Marco Pennekamp 708ed81eb2 [Test] Avoid importing unused @Nested annotations in generated tests
- Unused `Nested` imports frequently cause unused import warnings in the
  IDE, which are especially annoying in after-commit warning/error
  analysis.
2024-02-27 20:30:06 +00:00
Ilya Chernikov eab5164993 Scripting: fix script lowering in case of out of order declarations
The problem was that in K2 for some top-level script declarations we
need to add a dispatch receiver parameter (because frontend do not
assign any, but representing script as a class requires it to be the
script class) and at the same time, calls to these declarations rely on
properly set dispatch receiver parameter.
The simplest solution found is to have an additional traversal on the
relevan top-level declarations and assigning the dispatch receiver,
before running the main transformation.

#KT-64502 fixed
2024-02-23 22:03:44 +00:00
Ilya Chernikov 266447120d K2 scripting: treat default import similarly to K1
namely, add them to importing scopes directly and according to the
schema used for other implicit imports, rather than adding them
to the regular script file imports. See KT-65982 for explanation.
#KT-65982 fixed
2024-02-23 22:03:44 +00:00
Ilya Chernikov 9037975758 K2 Scripting: Skip base class params from resolution scope
The base class in scripting considered obsolete and therefore supported
via some ad-hoc mechanisms. In particular parameters to the base class
c-tor are passed via script provided properties. But in combination
with the resolution logic, this leads to issues described in KT-60452
This commits filters out such parameters from script resolution
scope and avoids this problem for now.
Bot it should be noted that proper diagnostics for properties shadowing
should still be implemented - see #KT-65809
#KT-60452 fixed
2024-02-23 22:03:44 +00:00
Yahor Berdnikau 6b19b8b9d0 [Repo] Don't use kotlinOptions in repo build scripts
^KT-63419 In Progress
2024-02-22 14:48:10 +00:00
Ilya Chernikov e5a6900458 K2 scripting: separate scripts compilation into another session
when scripts are compiled along with other sources.
#KT-65865 fixed
2024-02-21 07:47:15 +00:00
Ilya Chernikov 64cc6d2de0 minor: labels for script implicit receivers similar to context receivers 2024-02-21 07:47:15 +00:00
Ilya Chernikov 0d3964f22e Test, scripting: add infra for script tests with customizable def
based on the regular compiler tests infrastructure, but adding
directives that can customize the definition from testdata.
So far only default imports and provided properties are supported, but
the infrastructure is easily extendable to other customizations.
Another limitations that provided properties are not supported for
the black box tests - the constructor parameters computing code
should be adapted to support it.
Note: in order to pick up the customized definition, the script files
should have an extension .test.kts
2024-02-21 07:47:15 +00:00
Dmitrii Gridin 338c533a58 [FIR] FirScriptConfigurationExtensionImpl: change source element for result$$ property
We should use the source from replaced `FirAnonymousInitializer` as it
is more equivalent. Another point – the previous implementation
duplicated the source between generated FirProperty and initializer

^KT-65344
2024-02-13 14:58:31 +00:00
Dmitriy Novozhilov ed874262e3 [FIR] Part 3. Setup running platform checkers in CLI
^KT-58881
2024-01-24 10:45:00 +02:00
Marco Pennekamp 3497809ebd [Test] Add missing disposal for test root disposables
^KT-64099
2023-12-19 11:12:23 +00:00
Marco Pennekamp 32fe29b8cc [Test] Add debug names to unnamed test disposables
- This helps to track down disposables which are never disposed, and
  reduces confusion when printing disposables in general (the names will
  now be meaningful, instead of endless lists of "newDisposable" and
  "TestDisposable").

^KT-64099
2023-12-19 11:12:23 +00:00
Ilya Chernikov eeb723eb01 K2 Scripting: wrap script statements into blocks
(reuse anonymous initializers as block wrappers) so the top-level script
elements are all declarations now. Rename the property accordingly (
together with the previous commit).
It makes script more similar to the class and thus simplify e.g.
control flow analysis and resolve code.
2023-12-12 09:58:19 +00:00
Ilya Chernikov c9aee5bf09 minor: rename FirScript.statements do declarations...
to simplify the following commit that actually convert the types
and wrap statements into blocks.
2023-12-12 09:58:19 +00:00
Ilya Chernikov b0f44e8f69 K2 Scripting: mark parameters and DD containers with dedicated origins
needed for properly processing script CFG
2023-12-12 09:58:19 +00:00
Andrei Klunnyi 0a57c661fd Comment for LazyScriptDefinitionProvider's property
Relates to KTIJ-27951.
2023-12-07 16:37:35 +00:00
Ilya Chernikov a47ee44e65 Scripting: refactor test infrastructure - add missing stderr handling 2023-11-10 17:24:12 +00:00
Ilya Chernikov 02dc3c4ddb K2 Scripting: add annotation resolving for scripts
#KT-62400 fixed
2023-11-03 21:54:23 +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
Dmitrii Gridin f66bb1bcb7 [FIR] FirScriptConfiguratorExtensionImpl: avoid creation of dummy elements
This will reduce memory and CPU consumption

^KT-61186
2023-10-25 19:00:20 +02:00
Dmitrii Gridin 0b45c6ce23 [FIR] FirScriptConfiguratorExtensionImpl: provide source for script parameters
We need this source to be able to find the parent declaration

^KT-62693 Fixed
2023-10-20 09:27:21 +00:00
Ilya Chernikov 0aff76141b Fix comment on testScriptWithoutParams 2023-09-19 15:46:30 +00:00
Mikhail Glukhikh 45a12e0cfd LV 2.0: fix JvmIdeServicesTest.testDependency by allowing unstable deps 2023-09-19 15:46:29 +00:00
Yahor Berdnikau e71f86ee98 [repo] Fix configuration cache issues in scripting-compiler project 2023-09-19 15:46:28 +00:00
Ilya Chernikov 8a10070772 LV20 update scripting test mute logic for K2
after switching to LV20 by default
2023-09-19 15:46:28 +00:00
Ilya Chernikov 5b64741609 LV20: unmute scripting test
the test doesn't fail anymore, but should
see #KT-60452
2023-09-19 15:46:28 +00:00
Ilya Chernikov c639febf36 LV20: remove redundant scripting plugin registration
related to #KT-61452
2023-09-19 15:46:28 +00:00
Ilya Chernikov 7cbe728e35 LV20: mute scripting test testLazyScriptDefinitionDiscovery 2023-09-19 15:46:28 +00:00
Ilya Chernikov e3dae559d0 LV20: refactor K2 scripting tests - rename tasks 2023-09-19 15:46:27 +00:00
Ilya Chernikov 2c4cca5785 LV20: fix K2 scripting tests - plugin registration 2023-09-19 15:46:27 +00:00
Kirill Rakhman e0b5fa1de8 [FIR] Add opt-in for FirExpression.coneTypeOrNull in scripting
#KT-61367
2023-09-14 10:03:02 +00:00
Alexander.Likhachev 53fde520d5 [Build] Add jUnit dependencies in testApiJUnit5 to the implementation configuration
Adding these dependencies to the `api` configuration pollutes classpath for each dependant modules even if it doesn't need them. Instead, the dependencies should be declared more granularly if they're required
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Alexander.Likhachev 357d12fc8e [Build] Move JUnit dependencies into the version catalog
The `kotlin-test` dependencies are left untouched as changing them affects publications, thus these versions are independent from the used inside our build
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Mikhail Glukhikh f9c7a88175 Add -Xuse-fir-lt=false to some scripting tests
make them compatible with K2
2023-08-25 08:57:53 +00:00
Kirill Rakhman 8d7c5b375e [FIR] Replace usages of FirExpression.typeRef with coneTypeOrNull
#KT-59855 Fixed
2023-08-24 07:54:57 +00:00
Kirill Rakhman d0cc86f52c [Tests] Update test data after changes to FIR diagnostic messages 2023-08-21 16:28:48 +00:00
Dmitrii Gridin 35b0cd65e9 [FIR] PsiRawFirBuilder: add missing script configurator
PsiRawFirBuilder#visitScript didn't work because it didn't
have a configurator
Now FirScriptConfiguratorExtension split into two parts:
* File
* Script

^KT-60728
2023-08-02 16:50:45 +00:00
Andrei Klunnyi 419381af7f KT-60749 Scripting: default definition as a fallback
This commit effectively reverts changes made in the scope of KT-60193,
namely c9eebffb and 2d50bd68.

^KT-60749 fixed
2023-07-28 15:46:45 +00:00