Commit Graph

58 Commits

Author SHA1 Message Date
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
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
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
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
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
Kirill Rakhman 5b9c35de2e [Tests] Update test data with error suppression warnings
#KT-61129 Fixed
2023-08-18 13:29:20 +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
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
Dmitriy Novozhilov 36bb418049 [Parcelize] Add test for KT-47074 2023-01-31 07:53:08 +00:00
Dmitriy Novozhilov 4f3add8f7a [FIR] Fix resolution of plugin annotations if only meta annotations are registered 2023-01-04 11:02:01 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Ilya Chernikov 5b3816cce5 Test infra: refactor IGNORE_BACKEND directive
treat it as a general one, introduce *_K1 and *_K2 variants for
more specific ignoring
2022-11-12 16:28:23 +01:00
pyos 72e671c8f1 FIR Parcelize: allow anonymous local objects if they're enum entries 2022-09-28 15:14:25 +03:00
Steven Schäfer 58e51919bd Parcelize: Add missing FIR diagnostics 2022-07-26 09:34:10 +00:00
Ivan Kochurkin 8c7fad9a5e [FIR] Support of type arguments in annotations ^KT-48444 Fixed 2022-04-18 15:36:19 +00:00
Dmitriy Novozhilov 23f5c22684 [Test] Update testdata of parcelize 2021-12-15 21:37:32 +03:00
Dmitry Petrov df460a842b JVM_IR KT-50076 avoid CHECKCAST on moved dispatch receiver parameter 2021-12-13 14:13:34 +00:00
Dmitry Petrov 6f148c594f Revert "JVM_IR KT-50076 avoid CHECKCAST on moved dispatch receiver parameter"
This reverts commit 627d838343.
2021-12-13 14:13:33 +00:00
Dmitry Petrov 627d838343 JVM_IR KT-50076 avoid CHECKCAST on moved dispatch receiver parameter 2021-12-11 08:04:26 +00:00
Steven Schäfer 16a2aec296 Parcelize: Skip constructor checks when used with custom Parceler
See https://issuetracker.google.com/177850558
2021-12-08 11:07:10 +01:00
Steven Schäfer 58c687e42d Parcelize: Support @IgnoreOnParcel primary constructor parameters...
...with default values.

See https://issuetracker.google.com/177850560
2021-12-08 11:07:10 +01:00
Dmitriy Novozhilov edc74b8838 [Parcelize] Add test for Parcelable implementation with overriden describeContents 2021-11-23 15:01:33 +03:00
Dmitriy Novozhilov 8cdddbfd9d [FIR] Implement checkers for FIR parcelize plugin
There is one of checks left unimplemented (FirParcelizePropertyChecker.checkParcelableClassProperty)
  because it requires huge commonization of detecting which type can be
  serialized and which not, which is not prioritized job for now
2021-11-23 15:01:31 +03:00
Dmitriy Novozhilov eac9a9fc79 [FIR] Implement FIR version of parcelize plugin
This commit includes only generation of declarations and
  ir backend part, checkers are added in separate commit
2021-11-23 15:01:29 +03:00
Dmitriy Novozhilov 40d8451698 Add compiler diagnostic tests for parcelize checkers 2021-11-23 15:01:26 +03:00
Dmitriy Novozhilov b84ee64994 Move parcelize checkers testdata to :parcelize-compiler module 2021-11-23 15:01:23 +03:00
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00
Steven Schäfer 05da65654e Parcelize: Enable warnings in tests 2021-10-26 17:06:18 +02:00
Steven Schäfer ca74b7becc AsmLikeInstructionListingTest: Handle remaining instructions
Adds argument printing for TypeInsnNode, IincInsnNode,
MultiANewArrayInsnNode, InvokeDynamicInsnNode,
TableSwitchInsnNode, and LookupSwitchInsnNode.
2021-10-26 16:50:12 +02:00
Dmitriy Novozhilov f0aba5e892 [Test] Update parcelize bytecode testdata 2021-10-12 10:30:13 +03:00
Dmitriy Novozhilov df47bffabb [Test] Migrate Parcelize tests to new test infrastructure 2021-10-07 13:08:45 +03:00
Steven Schäfer 00134fddf9 Parcelize: Allow Parcelize annotation on sealed classes
See https://issuetracker.google.com/177856520
2021-09-28 22:16:33 +02:00
Steven Schäfer cb46a56815 Parcelize: Support unsigned array types
See https://issuetracker.google.com/200774823
2021-09-22 13:42:04 +02:00
Steven Schäfer 2501013012 Parcelize: Support ShortArray
ShortArrays are broken in the Parcelize JVM backend, which caused a
frontend error on the JVM IR backend.
2021-09-22 13:42:04 +02:00
Steven Schäfer fc013c6b9f Parcelize: Add an intrinsic to access Parcelable CREATOR fields
Fixes KT-19853.

The CREATOR field is a static field on a Parcelable class which is not
visible from Kotlin since the necessary metadata would have to be in a
Companion object which may not exist.

This commit adds a [parcelableCreator] function to kotlinx.parcelize,
which is optimized to a direct field access whenever possible.
2021-09-21 15:09:39 +02:00
Steven Schäfer 897c09bf8d Parcelize: Use the class loader of the Parcelable class for reading
In `readBundle`, `readPersistableBundle`, and `readValue`.
2021-09-21 15:09:04 +02:00
Steven Schäfer ae27be16eb AsmLikeInstructionListingTest: Print owner for FieldInsnNode 2021-09-18 00:25:58 +02:00
Dmitry Petrov bcafece28e Minor: update testData 2021-09-03 15:54:19 +03:00
Steven Schäfer b2e6e075ab Parcelize: Fix diagnostics for parcelable value classes 2021-08-31 02:48:03 +02:00
Steven Schäfer 9fd777cb7d Parcelize: Add support for unsigned types on the IR backend 2021-08-27 21:28:31 +02:00
Steven Schäfer 2f7bc8ca79 Parcelize: Add tests for parcelable value classes 2021-08-27 21:26:46 +02:00
Steven Schäfer a743669bc9 Parcelize: Fix type signatures in parcelable creator objects
These objects are visible from annotation processors and should not
refer to the type parameters of enclosing parcelable classes.
2021-08-27 21:26:46 +02:00
Steven Schäfer 0bbb36e765 Parcelize: Add tests for obsolete issues 2021-08-27 21:26:46 +02:00