Commit Graph

3874 Commits

Author SHA1 Message Date
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
Alexander Shabalin c491858a49 [K/N][tests] Add EnforcedHostTarget to atomicfu tests ^KT-65977 2024-02-27 13:20:50 +00:00
Vyacheslav Gerasimov f924de5a2c Build: Remove unused dependencies on :kotlin-compiler project
#KTI-1598
2024-02-27 10:29:59 +00:00
Jaebaek Seo 171ea3571c K2: Use deserialized type annotation for lambda type resolution.
This commit adds code to check whether a deserialized cone type is a
special function type kind or not when resolving the type of a lambda
expression (anonymous function). If it is a special function kind, it
sets the type of lambda based on the special function kind.

^KT-64994 Fixed
2024-02-25 10:10:43 +00:00
Jaebaek Seo 10a422180a K2: Propagate annotation of function type kind in compose plugin
We want to test whether the propagation of function type kind annotation
correctly works or not. This commit updates
ComposableFunctionsTransformer that mimics the real compose compiler
plugin to propagate the composable annotation i.e., @MyComposable from
MyComposableFunction kind. Finally, the generated IR function for lambda
expression must have the composable annotation, when the lambda
expression does not have the explicit composable annotation, but we
infer the composable annotation based on the annotation of function type
for the value parameter.

^KT-64994
2024-02-25 10:10:43 +00:00
Ilya Chernikov 0c5b700523 K2: fix annotation search on supertypes in assignment plugin
Current implementation checks only immediate supertype, while
in case of gradle build scripts DSL, the annotated superclass
is located deeper in the hierarchy.
The fix implements a recursive supertype check.

#KT-65983 fixed
2024-02-23 22:03:44 +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
Kirill Rakhman f231338cd6 [FIR] Render list of symbols with linebreaks as separators
#KT-61823 Fixed
2024-02-21 12:25:22 +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
Alexander Shabalin 9fb9d28277 [K/N][tests] Disable atomicfu tests with STATIC_EVERYWHERE ^KT-65977 2024-02-20 19:01:30 +00:00
Dmitriy Novozhilov e3dc0f0fa3 [Test] Register some identical checkers for specific handlers
- `FirIrDumpIdenticalChecker` for
    - `IrTextDumpHandler`
    - `IrPrettyKotlinDumpHandler`
- `FirIrSourceRangesIdenticalChecker` for
    - `IrSourceRangesDumpHandler`
- `FirIdenticalChecker` for
    - `FirDiagnosticsHandler`
2024-02-19 13:59:48 +00:00
Artem Kobzar 0d2c68664d [JS Plain Objects] Add README to the compiler plugin 2024-02-19 10:32:16 +00:00
Dmitriy Novozhilov acf2296590 [Test] Regenerate tests after two previous commits 2024-02-16 12:48:24 +00:00
Pavel Kunyavskiy e6f4d6e6fa [Tests] Use stable order for ir/kotlinLike dumps
^KT-65406
2024-02-16 10:19:38 +00:00
Nikolay Lunyak 7056ad5325 [FIR] Set status.isOverride for fake overrides
Even though SO may not be correct
overrides sometimes, it feels more
natural to treat fake overrides as...
well, "overrides". And without it
we'd need to make the code in
`FirOverrideChecker` less intuitive.
2024-02-15 16:10:13 +00:00
Nikolay Lunyak afd8895e51 [FIR] Introduce the PluginGenerated source kind
Make parcelize work consistently with
`FirOverrideChecker`.

Actually, there is a philosophical question about
what to do when a plugin generates a class
in a new package, and this class is red code
(for instance, doesn't implement an abstract
member from a supertype). There's no source
to report such an error, but we probably do
want to run checkers to avoid trying to
compile red code to binaries (because it may
crash in backend, or it may silently work).
2024-02-15 16:10:13 +00:00
Leonid Startsev 09e89db82f Change kotlinx- to kotlin- in kotlin-metadata-jvm and related projects
Change package, artifact group, artifact name, and Gradle module name to
kotlin-metadata and kotlin-metadata-jvm, respectively.

In Kotlin 2.0, kotlin-metadata-jvm library is promoted to stable, and is
a part of Kotlin distribution now.

Note that kotlinx-metadata-klib is left with org.jetbrains.kotlinx group, artifact name and package
because -klib part is considered not stable and for internal use. Since it is still published via Sonatype,
it should have kotlinx group. Therefore, it will have both classes from kotlin.metadata and kotlinx.metadata packages. This is not a problem, because we already had kotlinx.metadata split package between -jvm and -klib before.

#KT-63219 Fixed
2024-02-15 15:32:33 +00:00
Alexander Udalov 88fbaed22e Tests: minor, do not use target backend in kapt tests
These tests now only make sense for JVM_IR. Incidentally this fixes the
JVM illegal access warnings from generateTests, because the test
framework no longer tries to instantiate these tests (which leads to
`doOpenInternalPackagesIfRequired`) to determine the target backend.

The change in JvmEnvironmentConfigurator is needed so that JVM tests
without target backend would default to JVM IR instead of the old
backend.

Also rename files to match the class names.
2024-02-15 10:13:24 +00:00
Sergey.Shanshin 9a8ebd5c21 [KxSerialization] Cover all combinations of language and serialization features with tests for enums
Resolves https://github.com/Kotlin/kotlinx.serialization/issues/2324


Merge-request: KT-MR-13775
Merged-by: Sergei Shanshin <Sergey.Shanshin@jetbrains.com>
2024-02-14 13:15:01 +00:00
Dmitriy Dolovov 03418c11c3 [kotlinp] Change the package name in :tools:kotlinp-jvm subproject
Change the package name for all *.kt files inside
the :tools:kotlinp-jvm subproject from "org.jetbrains.kotlin.kotlinp"
to "org.jetbrains.kotlin.kotlinp.jvm"

^KT-62340
2024-02-13 21:01:08 +00:00
Dmitriy Dolovov d30efdb001 [kotlinp] Split :tools:kotlinp into "common" and "jvm" subprojects
The "common" subproject keeps only backend-neutral logic and depends
only on :kotlinx-metadata library. It takes the name of the former
project - :tools:kotlinp

The "jvm" subproject depends on the "common" one and also depends
on :kotlinx-metadata-jvm. It gets the new name - :tools:kotlinp-jvm

There is a lot of touched files in this commit. The majority of them
is just moved files (tests, test data, etc).

Only the following files were actually modified:
  .space/CODEOWNERS
  build.gradle.kts
  libraries/tools/abi-comparator/build.gradle.kts
  libraries/tools/kotlinp/build.gradle.kts
  libraries/tools/kotlinp/jvm/build.gradle.kts
  plugins/kapt3/kapt3-compiler/build.gradle.kts
  settings.gradle

 ^KT-62340
2024-02-13 21:01:08 +00:00
Dmitriy Dolovov eec76865a7 [kotlinp] Refactor to separate common part from JVM-specific part
This refactoring includes the following:
1. Separate backend-neutral part of the metadata printer `Kotlinp`
   from the part that accesses JVM-specifics: `JvmKotlinp`.
2. Introduce `org.jetbrains.kotlin.kotlinp.Printer`: The component
   that renders both individual `Km*` nodes and the whole metadata
   tree, and does so with the proper indentation.

^KT-62340
2024-02-13 21:01:08 +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
cristiangarcia f22688c4c8 Make :plugins:parcelize:parcelize-compiler:test ConfigurationCache compatible
Required for KTI-1553
2024-02-13 08:44:18 +00:00
Alexander Shabalin 7702374dbd [K/N][tests] In atomicfu make check task run all backends ^KT-65392
- test task will run JVM and JS backend tests; called by CI
- nativeTest will run Native backend tests; called by CI
- check will run all backends tests; called locally;
2024-02-12 17:52:38 +00:00
Sergey.Shanshin 2ae2f09fee [FIR] Fixed phase for FirCompanionGenerationProcessor to COMPANION_GENERATION
Phase COMPILER_REQUIRED_ANNOTATIONS causes errors in the kotlinx serialization tests:

org.jetbrains.kotlin.fir.symbols.FirLazyResolveContractViolationException: `lazyResolveToPhase(COMPILER_REQUIRED_ANNOTATIONS)` cannot be called from a transformer with a phase COMPILER_REQUIRED_ANNOTATIONS.
`lazyResolveToPhase` can be called only from a transformer with a phase which is strictly greater than a requested phase;
 i.e., `lazyResolveToPhase(A)` may be only called from a lazy transformer with a phase B, where A < B. This is a contract of lazy resolve
2024-02-12 15:54:11 +00:00
Sergey.Shanshin 84ad12be57 [KxSerialization] Added inspections on custom serializer parameters
Added inspections to check:
- custom serializer on class has as many parameters in primary constructor as the serializable class of type arguments
- all parameters in custom serializer has `KSerializer` type
- property in serializable class not parametrized by type parameter
- custom serializer on property of serializable class have no parameters in primary constructor
2024-02-12 15:54:11 +00:00
strangepleasures e363a1228d KT-65404 KAPT should print a warning if stub generation is triggered for an interface with method bodies but without -Xjvm-default=all or -Xjvm-default=all-compatibility
Merge-request: KT-MR-14139
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-02-12 11:17:32 +00:00
Pavel Mikhailovskii d75463a7d5 [KAPT] KT-65399 Fix rendering of types with names starting with $.
Solves a specific issue with Kotlin serialization, and most likely,
similar issues with synthetic classes.

Types with `$` in other positions will be still rendered incorrectly
due to imprecise conversion of such types from Kotlin to Java
in the analysis API.


Merge-request: KT-MR-14235
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-02-12 11:15:36 +00:00
strangepleasures 9688c3e761 [KAPT] Improve stub formatting; check raw stubs in tests
Merge-request: KT-MR-14244
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-02-09 15:41:37 +00:00
Pavel Mikhailovskii 7ab9e03347 KT-65684: KAPT: (Re)enable fallback to K1 KAPT and make it default
[KAPT] KT-65684 Set languageVersion=1.9 in KaptToolIntegrationTestGenerated

[KAPT] KT-65684 Re-enable a few now-passing tests in Kapt4IT

[KAPT] KT-65684 Fix the logic setting -Xuse-kapt4 flag in Kapt4IT.forceKapt4()

The change is needed to make sure that all the tests have the flag set,
 otherwise some of them would silently switch to the fallback node.
Also disables a few now failing tests.

[KAPT] KT-65684 Revert "KT-64385 Enable K2 KAPT by default"

This reverts commit 7e9d6e60


Merge-request: KT-MR-14291
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-02-09 12:54:28 +00:00
Alexander Udalov 3f034e8b67 Enable lightweight lambdas (aka invokedynamic) since 2.0
#KT-45375 Fixed
 #KT-58173 Open
2024-02-08 19:46:18 +00:00
Pavel Mikhailovskii f81b1150b2 [KAPT] KT-65453 Disable generation of type annotations in Java stubs
A workaround for KT-65608


Merge-request: KT-MR-14236
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-02-08 18:05:49 +00:00
Vladimir Tagakov 11d3ead975 jvm-abi-gen: Remove effectively private classes from ABI
#KT-64590 Fixed
2024-02-08 15:19:50 +00:00
Evgeniy.Zhelenskiy 7eab4b672d [K1, K2, CLI] Mark whole position range of compiler diagnostics in CLI
#KT-64989
2024-02-08 12:59:31 +00:00
Brian Norman 305c53dd6e [PowerAssert] Add codegen tests 2024-02-07 21:51:17 +00:00
Brian Norman aa34282efb [PowerAssert] Integrate with build
^KT-63617 Fixed
2024-02-07 21:51:17 +00:00
Brian Norman c3a60b127e [PowerAssert] Reformat files 2024-02-07 21:51:17 +00:00
Brian Norman 2de0c8b23f [PowerAssert] Update file copyright 2024-02-07 21:51:17 +00:00
Brian Norman d8167fe82b [PowerAssert] Update base package 2024-02-07 21:51:17 +00:00
Alexander Udalov 28797a31b4 JVM: refactor JvmDefaultMode, remove/rename some entries
- remove ENABLE/COMPATIBILITY because they can no longer be used
- remove forAllMethodsWithBody because its behavior is now equivalent to
  isEnabled
- inline isCompatibility
- inline DEFAULT
- rename ALL_INCOMPATIBLE -> ALL
2024-02-06 17:18:44 +00:00
cristiangarcia c897328af6 Make lombok tests CC compatible
Required for KTI-1553
2024-02-06 10:11:15 +00:00
Vladimir Tagakov dab9ac3b1c jvm-abi-gen: Allow disabling class members sorting in abi.jar
#KT-64589
2024-02-02 16:29:19 +00:00
Kirill Rakhman d047db850f [FIR] Fix nullability of function type created from custom function type
#KT-64706 Fixed
2024-01-31 08:52:58 +00:00
vladislav.grechko 9aa8fb80e7 Set correct IR origins for inc/dec operations
NB: in order to produce correct IR origins, the source element kinds for
some FIR elements has been changed. As a side effect, mapping PSI to FIR
slightly changed: namely, for `a[b]++`, `a[b]` used to be mapped on
`set` call or callable reference, but now it is mapped on `get` call.

^KT-61891: Fixed
^KT-64387: Fixed
2024-01-30 14:26:10 +00:00