Commit Graph

107598 Commits

Author SHA1 Message Date
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
Nikita Nazarov 438b2dd164 [K2, MPP] Actualize value class representation
^KT-63638 fixed
2024-01-03 16:39:56 +00:00
Dmitriy Novozhilov 0bd6ea764e [FIR] Consider only normal execution path during contracts verification
There might be several pathes out from the function from CFG point of view:
- normal execution path
- exceptional execution path

For verification of callsInPlace contract it's needed to check only
 the normal path

^KT-63414 Fixed
2024-01-03 14:18:46 +00:00
Dmitriy Novozhilov de9826683e [FIR] Unwrap named arguments during contracts verification
^KT-64501 Fixed
2024-01-03 14:18:46 +00:00
Dmitriy Novozhilov 6031f80e01 [Test] Reproduce KT-63414, KT-64500 and KT-64501 2024-01-03 14:18:46 +00:00
Brian Norman 3346cc4b19 [FIR] Lambdas without contracts should be considered repeatable
^KT-63777 Fixed
2024-01-03 14:08:04 +00:00
Dmitrii Gridin 8a3f850bca [LL FIR] StubBasedFirMemberDeserializer: deserialized properties must have default getter/setter
In FIR we always have either real getter/setter or the default one

^KT-62888 Fixed
^KT-62651 Fixed
2024-01-03 13:39:42 +00:00
Dmitrii Gridin db2849dc0d [Analysis API] add run configuration for standalone tests
^KT-62888
^KT-62651
2024-01-03 13:39:42 +00:00
Dmitrii Gridin 8de9d42b0d [Analysis API] use createSearchScopeByLibraryRoots for test libraries
As it is more similar to production. Also, fixed scope search for klib.
Now we register main binary modules before to avoid duplication with
libraries from createLibrariesByCompilerConfigurators as now we can
have a declared library and regular sources

^KT-62888
^KT-62651
2024-01-03 13:39:42 +00:00
Dmitrii Gridin 02d99769ff [Analysis API] Use library name in result jar
^KT-62888
^KT-62651
2024-01-03 13:39:41 +00:00
Dmitrii Gridin a341dc704f [Analysis API] Add symbol tests for properties from libraries
^KT-62888
^KT-62651
2024-01-03 13:39:41 +00:00