Commit Graph

108004 Commits

Author SHA1 Message Date
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
Alexander Kuznetsov b828365bb5 ReflectiveAccess: find the exact class the field is declared in
Affects IR Evaluator in IDEA.

The problem is happening because
`ReflectiveAccessLowering#fieldLocationAndReceiver` returns the class
 the field was called on, not the class the field was declared in.

 Then the class is used for obtaining a field by using reflection's
 `getDeclaredField` to make the field accessible after.
 But `getDeclaredField` doesn't work for field declared in a superclass,
 hence the error.

#KT-65012 fixed


Merge-request: KT-MR-13919
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2024-01-17 11:04:33 +00:00
Artem Kobzar dfe2d8651e [K/JS] Prepare JS Plain Objects plugin to publication 2024-01-17 10:52:58 +00:00
Alexander Korepanov 561be747c1 [JS FIR Tests] Add multimodule order test for FIR
^KT-64451 Fixed
2024-01-17 10:32:46 +00:00
Alexander Korepanov b672e5c131 [JS FIR Tests] Add source map smoke test for FIR
^KT-64450 Fixed
2024-01-17 10:32:46 +00:00
Roman Golyshev 6884266328 KTIJ-27841 [AA] Add explicit containingFile to ElementsToShortenCollector
This simplifies the code in a few places, and also allows to avoid
retrieving the `containingKtFile` from the PSI elements
2024-01-17 10:15:28 +00:00
Roman Golyshev 646cdb56e5 KTIJ-27841 [AA] Do not import and shorten class constructor if it will alter other references in the file
N.B. This implementation does not 100% prevent conflicts or resolve
alterations when shortening functions.
To guarantee that,
we would need to carefully consider all the references in the file,
and to check whether they have changed their resolve in the presence
of a new import.
This is not trivial and will be approached separately under a different
task.

^KTIJ-27841 Fixed
2024-01-17 10:15:28 +00:00
Roman Golyshev 1e2f612cbc KTIJ-27841 [AA] Add simple test cases for the classes with same name conflicts 2024-01-17 10:15:28 +00:00
Roman Golyshev 0e244b3fbf KTIJ-27841 [AA] Introduce intermediate ElementsToShortenCollector.importBreaksExistingReferences
This clarifies the semantics a little bit
2024-01-17 10:15:27 +00:00
Roman Golyshev 702be98927 KTIJ-27841 [AA] Refactor ElementsToShortenCollector.processCallableQualifiedAccess
Rename it, and return `ElementToShorten` from it
2024-01-17 10:15:26 +00:00
Roman Golyshev d0d29bea57 KTIJ-27841 [AA] Refactor ElementsToShortenCollector.findClassifierQualifierToShorten
Extract the cycle body into a separate function for clarity
2024-01-17 10:15:26 +00:00
Vladimir Sukharev 48df87f635 [K/N][Tests] Migrate two more cinterop tests
^KT-61259
2024-01-17 08:33:41 +00:00
Aleksei.Cherepanov 1e7e42baf2 [JPS] Improve JPS dumb mode
For the correct work of the compiler, some maps should be fulfilled by the build system. In the first implementation of dumb mode for JPS all maps were disabled. Now flag was introduced to determine IC behavior: to collect data needed for the compiler's code generation and disable maps and IC analysis

^KT-65043 Fixed
2024-01-17 08:22:27 +00:00
Aleksei.Cherepanov 32bc2b55ed Show compiler error in diff if JPS IC test fails 2024-01-17 08:22:27 +00:00
Kirill Rakhman 0cebf2b39f [Tests] Remove irrelevant code from test 2024-01-17 08:20:06 +00:00
Kirill Rakhman 00491a78f1 [FIR] Implement canBeNull for captured type by checking its supertypes
#KT-62959
2024-01-17 08:20:06 +00:00
Kirill Rakhman 7b0c4e5bf6 [FIR] Adapt assertion after #KT-62959 2024-01-17 08:20:06 +00:00
Kirill Rakhman ec78747f2b [Tests] Add test for #KT-62956 2024-01-17 08:20:06 +00:00
Kirill Rakhman 9d91eb2510 [FIR] Fix inference based on recursive upper bound
#KT-59012 Fixed
2024-01-17 08:20:06 +00:00
Kirill Rakhman 251827c9aa [FIR] Don't approximate captured types
This fixes some type argument mismatch errors caused by a captured type
being approximated and then captured again.
Some places need to be adapted to work with captured types that
previously only worked with approximated types.

#KT-62959 Fixed
2024-01-17 08:20:05 +00:00
Kirill Rakhman b6d7f35ebf [FIR] Implement capturing of captured types
This is in preparation of a future commit, where captured types won't be
approximated anymore after completion.

Consider a case like

class Box<T>(val value: T)
interface Foo<T> { fun bar() }

fun test(x: Box<out Foo<*>>) {
    x.value.bar()
}

The type of `x.value` will be `CapturedType(out Foo<*>)`.
Note that capturing only applies to the top level, i.e., nested
projections are not captured.
That's why it becomes necessary to support capturing of captured types,
otherwise the star projection in `CapturedType(out Foo<*>)` is not
properly captured in the receiver of the call `x.value.bar()`.

#KT-62959
2024-01-17 08:20:04 +00:00
Mikhail Glukhikh 3c20a7b82a K1/K2: add test for KT-62959 2024-01-17 08:20:04 +00:00
Roman Golyshev 67d32c3072 KT-64993 [AA] Unwrap safe call when deducing the expected type of function argument in KtFirExpressionTypeProvider
^KT-64993 Fixed
2024-01-16 22:36:59 +00:00
Roman Golyshev 318fd52567 KT-64993 [AA] Add test case for expected type in unsafe call arg 2024-01-16 22:36:59 +00:00
Roman Golyshev 72a0f2023d KT-64988 [AA] Unwrap safe call when resolving named arguments in FirReferenceResolveHelper
^KT-64988 Fixed
2024-01-16 22:36:59 +00:00
Vladimir Sukharev 80cf88c9b9 [K/N][Tests] Move threadStates tests to common codegen/box folder
^KT-61259
2024-01-16 20:15:25 +00:00
Sergey.Shanshin 96d7dc4fa6 [KxSerialization] Fixed access private custom serializer on property
When a custom serializer is specified on a type and this type is used in a property of another serializable class, then on the JVM this leads to an error accessing the custom serializer class - because it is private and located in another package.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2495


Merge-request: KT-MR-12877
Merged-by: Sergei Shanshin <Sergey.Shanshin@jetbrains.com>
2024-01-16 20:04:17 +00:00
wrongwrong ab76f94aa7 Reflection: minor, fix obsolete comment
InlineAwareCaller has already been renamed.
2024-01-16 20:03:58 +00:00
Vladimir Tagakov ad9c100137 Sort class members in jvm-abi-gen
#KT-64589 Fixed
2024-01-16 20:03:29 +00:00
Alexander Udalov 1a46b053f2 jvm-abi-gen: minor, refactor debug info and body removing visitors
Co-authored-by: Vladimir Tagakov <vtagakov@lyft.com>
2024-01-16 20:03:29 +00:00
Pavel Kunyavskiy 2bf5a58a30 [Fir2Ir] Don't use FirSyntheticProperty as the cache key
^KT-64871
2024-01-16 19:14:52 +00:00
Mikhail Glukhikh c3c215b6a4 CallableId: return pathToLocal to constructor (KT-58739) 2024-01-16 18:26:41 +00:00
Sergej Jaskiewicz 731eeb020d [JVM] Don't rely on presence of signatures in JVM IR serialization tests
This patch should not change any reasonable testing behavior. The only
case when the behavior could be changed is when two different functions
have the same IdSignature, which is a problem on its own.

Required for KT-64809
2024-01-16 18:25:58 +00:00
Alexander Shabalin 7d35c1087e [K/N] Make GlobalData be initialized lazily ^KT-64313 2024-01-16 16:54:58 +00:00
Anastasia.Nekrasova 7429dd4b94 K2: Support for inter-module interaction for @SubclassOptInRequired
The inter-module interaction was partially supported, but the
DiagnosticCompilerTestFE10TestdataTestGenerated and
LFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated were
failing. This is because the arguments of annotations were not fully
resolved in loadExperimentalitiesFromAnnotationTo function.

^KT-60262 Fixed
2024-01-16 16:53:04 +00:00
Nikolay Lunyak d66b38b7a9 [FIR] Introduce FirPropertySymbol.initializerSource 2024-01-16 14:18:09 +00:00
Nikolay Lunyak f08c167729 [FIR] Introduce FirValueParameterSymbol.defaultValueSource
It's easier to read the code if you don't
see generic `fir` access and thus don't
need to check all its usages to make sure
it's used correctly.
2024-01-16 14:18:09 +00:00
Nikolay Lunyak cb89695e21 [FIR] Review symbol.fir in FirVisibilityQualifierChecker
Also introduce `firForVisibilityChecker`.
This way it's easier to use compared to
defining overloads in `FirVisibilityChecker`
that accept symbols.

This change exists, because I wasn't able
to make myself sure that accessing fir here
is safe. We may come here after a typealias
expansion, after all.
2024-01-16 14:18:09 +00:00
Nikolay Lunyak 0b7e8c4708 [FIR] Add unwrapFakeOverridesOrDelegated for symbols 2024-01-16 14:18:09 +00:00
Nikolay Lunyak c7d535ff46 [FIR] Introduce ownTypeParameterSymbols 2024-01-16 14:18:09 +00:00
Nikolay Lunyak 3afed72027 [FIR] Remove symbol.fir from FirNativeObjCOverrideInitChecker 2024-01-16 14:18:09 +00:00
Nikolay Lunyak 95989fc3e2 [FIR] Remove unneeded symbol.fir accesses 2024-01-16 14:18:09 +00:00
Nikolay Lunyak 965d8d2fd5 [FIR] Abstract away symbol.fir in FirImportsChecker
It's easier to reason about correctness of
`symbol.fir` when it's localized in small
helper functions.
2024-01-16 14:18:09 +00:00
Nikolay Lunyak 52d712e110 [FIR] Introduce memberDeclarationNameOrNull 2024-01-16 14:18:09 +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
Vladimir Sukharev be9805ea5e [K2/N][Tests] Add test to demonstrate compiler behavior for ObjC properties intersection overrides
^KT-57640
2024-01-16 13:40:51 +00:00
Pavel Kunyavskiy e6fd523431 [IrFakeOverrideBuilder] Consolidate visibility handling
Now fake overrides declarations invisible for override
are totally ignored by FakeOverrideBuilder, instead of
creating fake overrides for them, and than filtering them
out later.

As side-effect it fixes KT-64972.

^KT-64974
2024-01-16 13:35:16 +00:00
Yahor Berdnikau 104e6a9b7c [Gradle] Suppress documentation for warnNpmGenerateExternals
^KT-58858 In Progress
2024-01-16 12:36:29 +00:00
Vladimir Sukharev 5f51f5e1fc [K/N] Migrate more cinterop tests
^KT-61259
2024-01-16 11:58:31 +00:00