186 Commits

Author SHA1 Message Date
Alexander Udalov e007153ae6 Parcelize: remove testData for old JVM backend
Old JVM backend implementation was removed in 163a052f98 along with
tests, but .asm.txt files were not removed.
2024-03-18 12:06:36 +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
Alexander Udalov 324d2e042a Tests: do not report backend diagnostics in diagnostic tests
There's a separate test data directory `testsWithJvmBackend` with a
runner that properly invokes the JVM backend and reports diagnostics
from it. All tests where JVM diagnostic presence/absence is important
were copied/moved there in this and previous commits.

The problem with the code removed in this commit is that it invoked some
parts of the _old JVM backend_ and old light classes, which is very far
from what users see in the production compiler at this point. This led
to real issues where we implemented incorrect behavior in K2 based on
the misleading diagnostic report from the K1 test.

The diagnostic in `triangleWithFlexibleTypeAndSubstitution4.kt` was
removed, but there's a copy of this test in `codegen/box/javaInterop`
which fails for K2 (KT-66529).

The diagnostic in `intersectionWithMappedSignature.kt` was removed and
that is OK because at this point CONFLICTING_JVM_DECLARATIONS there
seems like a bug in the old JVM backend.
2024-03-14 12:38:48 +00:00
Mads Ager b0bc017a16 [Parcelize] Add test for parcelize in multiplatform setting.
This tests that classes in common code can have code generated
for them in android compilations.
2024-03-14 06:52:19 +00:00
Mads Ager fa0d456850 [Parcelize] Allow parcelize to work on common code in multiplatform.
Since parcelize is Android specific, it should only be enabled for
Android compilation. In order to allow parcelize to generate code
for declarations in common code, we make checkers platform checkers
and we allow the registration of an additional annotations to
trigger parcelize processing.

That way, code such as:

```
package my.package

annotation class Parcelize

expect interface MyParcelable

@Parcelize
data class User(name: String): MyParcelable
```

Will work with an Android platform actual of the form:

```
actual typealias MyParcelable = android.os.Parcelable
```

And telling the plugin to trigger parcelize processing with the
additional annotation `my.package.Parcelize`.

Fixes https://issuetracker.google.com/315775835.
2024-03-14 06:52:19 +00:00
Mikhail Glukhikh 893e5cac94 Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551) 2024-03-13 20:38:44 +00:00
Wojciech Litewka 943be239ee [IR] Simplify IrFileImpl and IrExternalPackageFragment
#KT-65773 In Progress
2024-03-07 14:32:31 +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
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
Dmitriy Novozhilov acf2296590 [Test] Regenerate tests after two previous commits 2024-02-16 12:48:24 +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
cristiangarcia f22688c4c8 Make :plugins:parcelize:parcelize-compiler:test ConfigurationCache compatible
Required for KTI-1553
2024-02-13 08:44:18 +00:00
Dmitriy Novozhilov 727d2f46f8 [FIR] Part 1. Group checkers by the MPP kind
This commit introduces MppChecker kind, which represents the new property
  of checkers
- `MppCheckerKind.Common` means that this checker should run from the same
  session to which corresponding declaration belongs
- `MppCheckerKind.Platform` means that in case of MPP compilation this
  checker should run with session of leaf platform module for sources
  of all modules

An example of a platform checker is a checker that checks class scopes
  and reports ABSTRACT_NOT_IMPLEMENTED and similar diagnostics. If some
  regular class in the common module contains expect supertypes, the
  checker should consider the actualization of those supertypes to get
  a complete type scope

^KT-58881
2024-01-24 10:44:59 +02:00
Rafał Galczak c7d4a7e1f1 Add support for serializing kotlin.time.Duration in Parcelize plugin.
This commit adds support for the Parcelize plugin to generate default
serialization implementation for the kotlin.time.Duration. As Parcelize
already supports serializing some of the kotlin library types it makes
sense to support more common ones for the user convenience.

https://issuetracker.google.com/issues/264614661
2024-01-17 11:24:26 +00:00
Brian Norman eded51a0f5 [Parcelize] Detect redundant TypeParceler when type aliases are used
Make sure redundancies between class and property TypeParceler
annotations are detected when a type alias is used. This requires
checking the expanded type arguments of the annotation, as just
comparing the cone types is not sufficient because the type arguments
are not expanded.

^KT-64979 Fixed
2024-01-16 13:58:48 +00:00
Brian Norman 20340f94d4 [Parcelize] WriteWith Parceler type argument must be subtype of property
K2 checks that the entire Parceler of the WriteWith annotation is a
subtype of the expected Parceler for the property, while K1 only checks
that the type argument of the WriteWith Parceler is a subtype of the
property type. This mismatch leads to inconsistencies between K1 and K2
diagnostic reporting. Switch K2 to K1 behavior so diagnostics are
consistent.

^KT-60019 Fixed
2024-01-16 13:58:48 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Brian Norman 9ec469e3c3 [Parcel] Expand types from TypeParceler annotation to support aliases
Class properties are being expanded before checking for custom
parcelers, which makes custom parcelers of type alias unable to be
found. To maintain K1 behavior, the custom parceler type must also be
expanded, so even the aliased type is supported when used in its raw
form as a class property.

^KT-64707 Fixed
2024-01-04 19:59:56 +00:00
Brian Norman 645970fa7a [Parcelize] Fix subclass check of deprecated Parceler interface
^KT-59949 Fixed
^KT-60090 Fixed
2023-12-14 16:36:07 +00:00
Vladimir Sukharev ec3dd43edc [Tests] Enforce FIR_IDENTICAL for Fir tests with IrTextDumpHandler
^KT-64256 Fixed
2023-12-13 22:39:45 +00:00
Ilya Gorbunov d2aae67e03 Replace kotlin-test project dependencies in the project
Use dependency helper function that chooses whether to take them
from the bootstrap repository or from a configuration of kotlin-test

KT-61969
2023-12-13 15:40:25 +00:00
Alexander.Likhachev a19bd2ed2e [Build] Migrate most of the build logic from Project.buildDir usage
It's going to be deprecated in Gradle 8.3

There's currently no way to pass a `org.gradle.api.provider.Provider` to the JavaExec.systemProperty or Test.systemProperty. There's a workaround using `org.gradle.process.CommandLineArgumentProvider`, but I intentionally don't rework these calls as Gradle is going to allow passing providers to configure system properties: https://github.com/gradle/gradle/issues/12247#issuecomment-1568427242
^KTI-1473 In Progress
2023-12-07 18:31:06 +00:00
Brian Norman 0d36462c58 [Parcelize] Align checker and generator on valid Parcelize classes
A previous fix to the generator made the generator and checker
validation of classes which could be parcelized different. The checker
would report error in cases where the generator would not generate
anything. Align these checks, with improved code sharing, so errors are
not reported on classes which will not have parcelize components
generated.

^KT-63086 Fixed
2023-11-08 14:35:28 +00:00
Brian Norman f8ee8adfde [Parcelize] Fully expand type aliases when checking for RawValue
^KT-61432 Fixed
2023-11-08 12:48:36 +00:00
Kirill Rakhman 87563f3aea [FIR] Rename diagnostic renderers that insert quotes and fix some messages
#KT-62386
2023-10-27 13:27:35 +00:00
Dmitriy Novozhilov fb8bf19091 [IR] Rename IrSymbolInternals to UnsafeDuringIrConstructionAPI
The new name more precisely describes the meaning of this opt-int
2023-10-25 11:32:46 +00:00
vladislav.grechko 897eab6b50 Do not add nullability annotations to the methods of local classes
Nullability annotations are useless for the methods of local classes
due to their restricted scope.

^KT-62513: Fixed
2023-10-18 19:48:38 +00:00
Ilya Gulya f6b2c642c2 Support kotlinx.collections.immutable in kotlin-parcelize plugin
#KT-57685 Fixed

Co-authored-by: Ilya Gulya <ilyagulya@gmail.com>
2023-10-02 23:29:43 +00:00
Nikolay Lunyak 986f1624ec [FIR] Remove jvm-specific annotations from common compiler code
^KT-54596 Fixed
2023-09-19 22:14:09 +00:00
Alexander.Likhachev 6eaccc997f [Build] Fix the typo junit jupyter -> jupiter 2023-09-06 22:47:34 +00:00
Alexander.Likhachev 6f96be0b76 [Build] Get rid of the testApiJUnit5 method
#KTI-1349 In Progress
2023-09-06 22:47:34 +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
Vyacheslav Gerasimov 009cda0c60 Build: Make robolectric tests run offline without downloading artifacts
#KTI-1367
2023-09-04 08:57:19 +00:00
Kirill Rakhman de1c92a32f [FIR] Update diagnostic messages 2023-08-21 16:28:48 +00:00
Kirill Rakhman 5b9c35de2e [Tests] Update test data with error suppression warnings
#KT-61129 Fixed
2023-08-18 13:29:20 +00:00
Ilya Kirillov bdfc68468f [FIR] optimize direct allocation of empty ConeTypeProjection arrays
On the snapshot from KTIJ-26260 empty ConeTypeProjection arrays take about 10mb
2023-08-18 11:36:42 +00:00
Dmitriy Novozhilov 697d0d5638 [IR] Mark IrSymbol.owner with OptIn annotation
^KT-60923 Fixed
2023-08-16 17:47:29 +00:00
Alexander Udalov 755d140e16 Parcelize: do not copy call in ParcelizeIrTransformer
This is just a refactoring/optimization that makes use of the fact that
IrCall.symbol and IrFunctionReference.symbol are now mutable.
2023-06-22 17:19:00 +00:00
Sergej Jaskiewicz 0b7db067e6 [IR] Reorder parameters in IrFactory#createField
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-22 15:55:02 +00:00
Brian Norman b595328192 [Parcelize] Ignore all sealed classes in Parcelize FIR generator
Sealed classes are inherently abstract and should not have Parcelable
functions added via the FIR declaration generator.

#KT-59112 Fixed
2023-06-08 12:58:32 +00:00
Alexander Udalov d757847ed6 JVM: enable -Xlambdas=class for some backend tests
These tests are checking the specifics of the class-generated lambdas.
2023-05-12 15:21:00 +00:00
Kirill Rakhman a818c543a9 [FIR] Verify diagnostic messages don't reference non-existent parameters 2023-04-27 12:54:31 +00:00
Nikolay Lunyak e3d313dd02 [FIR] Introduce the proper Fir2IrResultsConverter
Sometimes when running MPP tests we may
observe js-specific modules running with
the jvm-specific fir2ir converter
(probably because the name didn't contain
the JVM affix).
2023-04-25 11:29:34 +00:00
Roman Golyshev 83f9e0f87e [213] Add more missing runtime dependencies
KTI-1114
2023-04-21 13:19:04 +00:00
Roman Golyshev ac388010b1 [213] Add missing test runtime dependencies
KTI-1114
2023-04-21 13:19:04 +00:00
Nikolay Lunyak 20786bb35a [FIR] Refactor the default messages presence checking
Forbid calling `checkMissingMessages` accidentally
outside tests.

Checking Parcelize default messages inside a test.
2023-04-14 13:07:03 +00:00
Alexander Udalov 163a052f98 Remove old JVM backend implementation of Parcelize
There's no way for the end user to use this implementation anymore,
since old JVM backend cannot be enabled, and nothing else from Kotlin
depends on it.
2023-03-13 13:53:08 +01:00
Steven Schäfer 669ac1ae30 Parcelize: Handle nullable sparse arrays
Fixes https://issuetracker.google.com/269956252
2023-03-02 12:47:17 +01:00
Kirill Rakhman 9dda5e4fcd [Test] Remove redundant FIR_DISABLE_LAZY_RESOLVE_CHECKS directives
KT-56177
2023-02-28 10:19:18 +00:00