Commit Graph

107608 Commits

Author SHA1 Message Date
Dmitriy Novozhilov fb3963dead [FIR] Add extension point to metadata serialization
This is a temporary solution for KT-64312
Introduced extension point should be removed (KT-64695)
2024-01-05 11:30:57 +00:00
Dmitriy Novozhilov 717d1c774b [FIR] Save information about SerializationPluginMetadataExtensions in the property attribute
K1 implementation of kotlinx.serialization used SerializationPluginMetadataExtensions
  for two purposes:
- to extract the source-order of properties
- to identify which properties are actually serializable

In K2, the first point is covered by the compiler itself (as it correctly orders
  properties during deserialization), and to cover the second point we
  need to save in the propery information if it was mentioned in this extension
  or not

KT-64312
2024-01-05 11:30:57 +00:00
Alexander Shabalin 5208b3c024 [K/N] Put FinalizerProcessor CFRunLoop usage under a flag ^KT-64313 2024-01-05 10:46:49 +00:00
Dmitriy Novozhilov 8ff869a08c [FIR] Unregister FirJavaElementFinder at the Project disposing
^KT-64433 Fixed
2024-01-05 10:23:04 +00:00
Pavel Kunyavskiy 32de968531 [Names] Avoid deadlock in initialization of classId constants
StandardClassIds was using Annotations subclass in its initialization.
At the same time, Annotations subclass was using StandardClassIds in its
initialization implicitly through baseId() method.

This leads to a rare deadlock on CI in case where two different threads
tried to initialize both classes at the same time.

It can't be reproduced robustly, as a single thread was able to
successfully initialize both, and will do it on an attempt to
initialize any of them.

^KT-64720 Fixed
2024-01-05 09:53:05 +00:00
Dmitriy Novozhilov 7accda6cda [FIR] Make FirProviderWithGeneratedFiles know about providers from mpp dependencies
During refactoring of FIR2IR commit 8ebb4127 introduced
  `FirProviderWithGeneratedFiles` for lookups for containing FIR for
  generated declaration

But it broke the logic of `Fir2IrIrGeneratedDeclarationsRegistrar`,
  which provides annotations for metadata from generated IR annotations
  (see `containingFile` function in it), as it started to use fir
  provider from the platfrom session instead of provider of the
  corresponding session

So to fix this issue `FirProviderWithGeneratedFiles` was changed in the
  way so it sees declarations from dependant sessions too (only with
  `dependsOn` relation), which allows to use provider for the leaf
  platform session for declarations from any module within the same
  HMPP hierarchy

^KT-64444 Fixed
2024-01-05 09:42:22 +00:00
Roman Golyshev 8feb4def4d KTIJ-28167 [AA] Add a note about type aliases to the findAvailableConstructors function 2024-01-04 20:07:41 +00:00
Roman Golyshev df8c6c694a KTIJ-28167 [AA] Support SAM constructors in KtFirReferenceShortener
Utilize `FirSamResolver` to obtain the potential SAM constructor
from the classifier

Also, accept K2_SYNTHETIC_RESOLVED in the `resolveUnqualifiedAccess`,
since this is the kind of resolve success which corresponds to the
SAM constructor call resolution

^KTIJ-28167 Fixed
2024-01-04 20:07:41 +00:00
Roman Golyshev e561de8a22 KTIJ-28167 [AA] Refactor FirShorteningContext.findFunctionsInScopes
It will make it easier processing SAM constructor there later
2024-01-04 20:07:41 +00:00
Roman Golyshev 31291fc8fa KTIJ-28385 [AA] Support SAM constructors in computeImportableName
This allows to properly report them as used in `KtFirImportOptimizer`

This change will also be important for properly fixing KTIJ-28167,
since `computeImportableName` is also used in reference shortener

^KTIJ-28385 Fixed
2024-01-04 20:07:41 +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
Vladimir Sukharev 55bff799a8 [K/N][tests] Split tests for Any.collectReferenceFieldValues
^KT-61259
2024-01-04 18:24:37 +00:00
Vladimir Sukharev d972fec13c [K/N][tests] Move tests into better places
^KT-61259
2024-01-04 18:24:37 +00:00
Vladimir Sukharev e68bd1f04f [K/N][tests] Adjust moved tests to new testing infra
^KT-61259
2024-01-04 18:24:37 +00:00
Vladimir Sukharev 0a0da76a56 [K/N][tests] Move some more native tests to new testing infra
^KT-61259
2024-01-04 18:24:37 +00:00
Pavel Kunyavskiy 4080776fe3 [Fir2IR] Set correct module descriptors for builtins
^KT-64420
2024-01-04 17:29:58 +00:00
Alexander Shabalin d665eb3575 [K/N] Fix calls checker allow list for signposts ^KT-62689 2024-01-04 16:58:20 +00:00
Dmitrii Gridin 44388ea15f [SLC] generate correct name for property assessors in case of JvmRecord
^KT-62357 Fixed
2024-01-04 16:32:10 +00:00
Dmitrii Gridin 5c71015b09 [LC] implement isRecord for classes
Java world should better understand our classes with JvmRecord annotation

^KT-62357
2024-01-04 16:32:10 +00:00
Dmitrii Gridin b463f1fdfa [SLC] unmute tests on JvmRecord
^KT-62357
2024-01-04 16:32:10 +00:00
Ivan Kochurkin 69b9bfc3e0 [FIR] Initialize public visibility for class-like declarations at FIR building phase if no modifier is presented
Java resolving subsystem requires calculated visibility for correct disambiguation of supertypes.
But visibility remains `Unknown` for Kotlin class-like declarations during supertypes resolving because `STATUS` resolve phase is performed after `SUPER_TYPES` phase.
To fix the problem, the visibility should be initialized to public at the FIR building phase if no modifier is presented.

^KT-64127 Fixed
2024-01-04 16:17:32 +00:00
Alexander Udalov ee8d42532b Fir2Ir, JVM IR: support flexible Array types loaded from Java
We don't have true flexible types in the IR, but we approximate it with
internal type annotations, such as FlexibleNullability,
FlexibleMutability, RawType. These annotations are then handled
specially in JvmIrTypeSystemContext, which can construct a fake flexible
type so that type checker on IR types would behave exactly as on
frontend types.

As shown in KT-63441, one instance of flexible types where flexibility
was lost during conversion to IR is Java array/vararg types. It's
necessary to support it so that IR fake overrides could be constructed
correctly, because IR fake override checker requires parameter types to
be equal. So this change introduces another internal type annotation,
FlexibleArrayElementVariance, which is only applicable to types with
classifier kotlin/Array, and which signifies that the annotated type
`Array<X>` should rather be seen as `Array<X>..Array<out X>`.

 #KT-63441 Fixed
 #KT-63446 Fixed
2024-01-04 15:54:27 +00:00
Alexander Udalov e98902ce74 Fir2Ir, JVM IR: minor, deduplicate constants for ClassId of special annotations 2024-01-04 15:54:26 +00:00
Dmitrii Gridin 3fcf5c47c2 [resolution] KotlinJavaPsiFacade: replace explicit EMPTY_SCOPE check with more general
Someone can request search for `LocalSearchScope.EMPTY` and we can
catch this case

^KT-62892
2024-01-04 15:20:38 +00:00
Dmitrii Gridin 37ccf5d4f3 [resolution] KotlinJavaPsiFacade: do not return classes with wrong ClassId
We shouldn't return from `findClass`/`findClasses` Java classes with
`ClassId` different from the requested one

^KT-62892
2024-01-04 15:20:38 +00:00
Dmitrii Gridin c6004874c1 [SLC] generate light classes for functions with JvmName and value class as parameter
Such functions/accessors have not-mangled names, so they can be called
from Java

^KT-63087 Fixed
2024-01-04 15:16:20 +00:00
Dmitrii Gridin e0f524b6b3 [LC] add tests on declarations with JvmName and value classes
^KT-63087
2024-01-04 15:16:20 +00:00
Brian Norman aae8cd2a7c [FIR] Local variable assignment must be propagated before loops
When performing lookahead for local variable assignments, make sure
assignments taking place within loops are being propagated before loops.
This makes sure smartcasts within non-inline declarations before the
loop are disallowed.

^KT-63867 Fixed
2024-01-04 14:20:21 +00:00
Kirill Rakhman 10d6d95ee8 [Tests] Add regression test for #KT-64702 2024-01-04 14:12:42 +00:00
Nikolay Lunyak 533ed5c622 [FIR] Unwrap typealias-bounds in FirTypeParameterBoundsChecker
This change makes sure the test introduced
in the previous commit doesn't crash
the compiler.

^KT-64644 Fixed
2024-01-04 14:08:43 +00:00
Nikolay Lunyak 7c3042772e [FIR] Reproduce KT-64644
Ensure the given code crashes the
compiler.

^KT-64644
2024-01-04 14:08:43 +00:00
Igor Chevdar aaf34c3436 [IR] Fixed a bug with local classes extraction from lambdas
#KT-64508 Fixed
2024-01-04 11:15:18 +00:00
Igor Chevdar 54328a1db4 [K/N][tests] Added a reproducer for #KT-64508 2024-01-04 11:15:18 +00:00
Kirill Rakhman 7fb5cbd1f8 [FIR] Implement UNNECESSARY_NOT_NULL_ASSERTION checker for java warning level types 2024-01-04 09:59:50 +00:00
Kirill Rakhman d6bd31b313 [FIR] Implement UNNECESSARY_SAFE_CALL checker for java warning level types
#KT-63528 Fixed
2024-01-04 09:59:50 +00:00
Nikolay Lunyak 9c0ac27307 [FIR] Don't miss annotations on properties from primary constructors
^KT-64609 Fixed
2024-01-04 09:45:27 +00:00
Nikolay Lunyak 1f46aed3e0 [FIR] Reproduce KT-64609
^KT-64609
2024-01-04 09:45:27 +00:00
Dmitrii Gridin af5f76048b [SLC] AbstractSymbolLightClassesByPsiTest: add more stable order
Now more diff between sources and libraries are readable.
Also prefer .descriptors to .fir as FIR is a first-class support

^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin d64f18eaa9 [SLC] AbstractSymbolLightClassesStructureTestBase: add stable order
Now more diff between sources and libraries are readable

^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin 2bad2f37ce [LL FIR] add missed ClassId check for combined Java classes symbol provider
findClasses works over regular `PsiElementFinder`, which doesn't know
about out ClassId conception. So, `a/b/A.B` and `a/b/A/B` are the same
from `FqName` point of view.
`FirJavaFacade` has this check, so this problem appears only in the case
of combined provider.

^KT-62892 Fixed
2024-01-03 21:35:12 +00:00
Dmitrii Gridin a39688ba10 [LL FIR] add tests on fir for full qualified name for nested classes
For some reason, outer Java class is treated as a package

^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin 4cb75490db [LL FIR] AbstractLowLevelApiLastModuleFirstFileTest: replace moduleStructure with testModule
We can get the module structure from `TestServices`,
so current file is more preferable

^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin 7efbcad121 [Analysis API] add diagnostic tests for inner Java class usage
^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin 6c7d1babf0 [Analysis API] support Java compilation in tests
Previously we just skipped Java sources.
The order of classes in light classes test data is changed due to
differences in implementations of `compileLibraryToJar` and `runJvmCompiler`

^KT-62892
2024-01-03 21:35:12 +00:00
Alexander Udalov a9f85d75f4 Kapt: remove support for old JVM backend
#KT-64680 Fixed
2024-01-03 19:37:40 +00:00
Alexander Udalov c251eb19a6 Kapt: remove old JVM backend test data (2/2)
In this commit, .ir.txt expectation test data files for the JVM IR
backend are renamed to .txt. This is done as two separate commits so
that Git would recognize that these files were logically moved, not that
the contents of the original .txt files were changed.

 #KT-64680
2024-01-03 19:37:40 +00:00
Alexander Udalov 9c67616b25 Kapt: remove old JVM backend test data (1/2)
In this commit, .txt expectation test data files for the old JVM backend
are deleted.

 #KT-64680
2024-01-03 19:37:40 +00:00
Alexander Udalov e4a608c6e7 Kapt: remove tests on old JVM backend
#KT-64680
2024-01-03 19:37:40 +00:00
Alexander Shabalin eea89c7f23 [K/N] Enable safepoint signposts by default ^KT-62689 2024-01-03 18:30:59 +00:00
Kirill Rakhman 1018ff280e [FIR] Fully expand the bounds of type parameters for canBeNull check
This is required because a not-null bound `Foo` can resolve to a
`typealias Foo = Bar?` in which case we must return true.

#KT-64645 Fixed
2024-01-03 17:15:50 +00:00