Commit Graph

21 Commits

Author SHA1 Message Date
Dmitrii Gridin 7620289f6f [FIR] fix contract violation from meta annotations
^KT-60448 Fixed
2023-07-18 16:50:25 +00:00
Sergey.Shanshin 5ba1b36796 [KxSerialization] Change visibility for synthetic functions
- synthetic constructor became internal for final classes
- write$Self became internal for final classes

Resolves https://github.com/Kotlin/kotlinx.serialization/issues/2209

Merge-request: KT-MR-9068
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-07-14 17:36:22 +00:00
Sergey.Shanshin 3629a9db30 [KxSerialization] Added inspection on abstract custom serializer
Serialization requires an instance of the serializer, which cannot be obtained with the passed interface, abstract or sealed class.
Therefore, the specifying of such classes in `Serializable` annotation must be prohibited.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2173
Relates #KT-58036

Merge-request: KT-MR-10753
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-07-04 18:31:35 +00:00
Leonid Startsev 6ee20574e1 Correctly handle @Repeatable @SerialInfo annotations on classes
that were affected by deduplication of inherited serial info annotations.

Prohibit combination of @InheritableSerialInfo and @Repeatable.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2099
2023-03-20 18:15:09 +00:00
Dmitriy Novozhilov 507ef3e951 [FIR] Properly handle declarations from other source sessions in FirPredicateBasedProvider
^KT-57083 Fixed
2023-03-16 15:13:19 +00:00
Leonid Startsev 5cf1c01273 Expand type aliases in K2 when checking if serializable class' properties
have serializers.

#KT-56594 Fixed
#KT-56480 Fixed
2023-03-14 12:11:32 +00:00
Artem Kobzar 50a462fed1 [K/JS] Exclude kotlinx.serialization synthetic declarations from JsExport
^KT-57024 Fixed
2023-02-28 18:11:36 +00:00
Sergey.Shanshin c9b8160f1e [kxSerialization] Added diagnostic on useless Serializer annotation
Resolves Kotlin/kotlinx.serialization#2182

Merge-request: KT-MR-8718
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2023-02-14 22:00:33 +00:00
Leonid Startsev a1894ed027 Update runtime dependency in kotlinx.serialization plugin tests to 1.4.1 2023-01-09 18:25:42 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Dmitriy Novozhilov 6864433581 [FIR] Support resolution of meta-annotations before supertypes
Now annotations are resolved with following algorithm:
1. On COMPILER_REQUIRED_ANNOTATIONS we resolve all annotations
     and store results if this is compiler annotation, plugin annotation,
     or annotation with meta-annotation (meta annotations are checked
     recursively with designated resolution if needed)
2. On TYPES stage we resolve all those annotations once again and if
     some annotation changes resolution then we keep type from p.1 and
     report error on this annotation, so user should disambiguate it

Ambiguity may occur because of nested annotations with same name as
  plugin annotations:

```
annotation class SomeAnnotation // (1) plugin annotation

open class Base {
    annotation class SomeAnnotation // (2)
}

class Derived : Base() {
    @SomeAnnotation // <-----------------
    class Inner
}
```
At COMPILER_REQUIRED_ANNOTATIONS annotation call will be resolved to (1)
  because at this stage supertypes are not resolved yet, and we consider
  only importing scopes. At the TYPES stage we will find correct
  annotation from supertype
2022-12-01 07:29:39 +00:00
Leonid Startsev f627d81d53 Make diagnostic for @MetaSerializable on nested annotation
K2 plugin API has a limitation that meta annotations from plugin predicates
can't be used on nested annotations because their resolve process includes supertypes
resolve, that can be affected by the plugin itself. Therefore, @MetaSerializable
can't be applied to nested annotation classes in K2, which is reflected by
this diagnostic.

For old FE, diagnostic is lowered to WARNING with deprecation message.
2022-11-22 10:53:28 +00:00
Leonid Startsev 76fc7ce0ad Fix creating FirSerializableProperties for external classes.
External classes do not have primary constructor, so we need to use 0 as
value parameter count for them to be externally serializable when possible.
2022-11-22 10:53:27 +00:00
Leonid Startsev 4cf50d7d23 Add checker for companion objects inside serializable class:
Warning for old FE, error in FIR

#KT-54441 Fixed

Merged-by: Leonid Startsev <leonid.startsev@jetbrains.com>
2022-10-20 10:18:04 +00:00
Sergey.Shanshin 5a1c2c56bd Added support of external serializers to the FIR
Co-authored-by: Leonid Startsev <leonid.startsev@jetbrains.com>
Merge-request: KT-MR-7334
Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
2022-10-13 15:25:39 +00:00
Leonid Startsev 090aec6b3b Prohibit Array<T> in @Serializable classes
because it's impossible to correctly create array reflectively without
knowing correct KClass.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1243
2022-10-12 11:48:21 +00:00
Dmitriy Novozhilov 671083c701 [Serialization] Implement serialization checker for K2 version of plugin
^KT-53178 Fixed
2022-09-07 07:57:38 +00:00
Dmitriy Novozhilov a6d3c6e5c6 [Serialization] Suppress OPT_IN errors in all diagnostic tests 2022-09-05 10:20:06 +00:00
Dmitriy Novozhilov 84b8ab1f9c [Serialization] Add DiagnosticsTests for FIR 2022-09-05 10:20:06 +00:00
Dmitriy Novozhilov a2ffba275c [Serialization] Migrate all tests to new test infrastructure 2022-09-05 10:20:05 +00:00
Dmitriy Novozhilov cc00dcc038 [Serialization] Reorganize module structure 2022-08-22 17:23:18 +03:00