Commit Graph

106151 Commits

Author SHA1 Message Date
Ivan Kylchik 32057f6d10 [JVM_IR] Use createSimpleNamedCompilerPhase to create lowerings 2023-11-01 14:01:17 +00:00
Ivan Kylchik f5bb477459 [JVM_IR] Move all stickyPostconditions into single lowering
`stickyPostconditions` are such conditions that are checked
every time after applying when a new lowering finishes its execution.
Right now we are using them only in JVM, and this is a blocker
for adopting Native approach for lowering execution.

In Native we are using
`SimpleNamedCompilerPhase<in Context : LoggingContext, Input, Output>`
as the common super type for all lowerings. Here we have `Input` and
`Output` that can potentially be different and `stickyPostconditions`
don't have much sense in that case.
2023-11-01 14:01:17 +00:00
Ivan Kylchik 6a02a26db8 [Native] Move createSimpleNamedCompilerPhase into common.phaser.PhaseBuilders
This is needed to be able to reuse these functions
for other backends.
2023-11-01 14:01:17 +00:00
Ivan Kylchik 465fc9116e [IR] Drop some old lower utils that are not used anymore 2023-11-01 14:01:17 +00:00
Dave MacLachlan 722ddc9f91 Use fileKey instead of canonicalPath when deduping files
`resolveDependencies` showed up as a hotspot when profiling due to `canonicalPath` doing a lot of file system calls.
`fileKey` is more efficient and should guarantee uniqueness (`canonicalPath` may fail in the case of hardlinks).
The new code is 3x faster in our use case.
2023-11-01 13:59:13 +00:00
Ilya Goncharov 3673dff959 [FIR] Only one specific diagnostic for data class without parameters left
^KT-60042 fixed
2023-11-01 13:58:44 +00:00
Alexander Shabalin 17dc60aac9 [K/N] Migrate runtime/text tests to new testing infra ^KT-61259 2023-11-01 13:56:10 +00:00
Brian Norman e9983a947f [FIR] Add checker for EXPANSIVE_INHERITANCE
^KT-59402 Fixed
2023-11-01 13:53:57 +00:00
Anastasiia Spaseeva a991a13295 Reproducible builds: convert instruction to the template
^Relates to KTI-1222
2023-11-01 12:59:13 +00:00
Roman Golyshev 236a76f779 KT-62676 [AA] Small refactoring of AbstractReferenceShortener*Test 2023-11-01 09:45:40 +00:00
Roman Golyshev b0f15451fd KT-62676 [AA] Collect redundant this qualifiers in reference shortener
^KT-62676 Fixed
2023-11-01 09:45:40 +00:00
Roman Golyshev 4ca1f9d492 KT-62676 [AA] Introduce ShortenOptions class
This class should contain 'global' settings for reference shortening;
ATM it only contains the `removeThis` flag

In the future this setting might be merged together with
`ShortenStrategy` to be computed on per-element basis
2023-11-01 09:45:40 +00:00
Roman Golyshev adf7ee4535 KT-62676 [AA] Rename ShortenOption -> ShortenStrategy
`Option` is going to refer to more global settings of the
reference shortener (like shortening `this` or `Companion`
references)
2023-11-01 09:45:39 +00:00
Vladimir Sukharev 9e7bb90e44 [K/N] Don't pass language version to the second stage. 2023-11-01 01:51:12 +00:00
Mikhail Glukhikh d6cefb363b K1/K2: add test to confirm KT-61100 behavior 2023-10-31 22:13:10 +00:00
Mikhail Glukhikh af58b30e5f K2 Java: fix 'value' annotation constructor parameter type to Array<out>
#KT-61100 Fixed
2023-10-31 22:13:10 +00:00
Vladimir Sukharev 8e4a6759a4 [FIR] Fix Disappeared INVALID_CHARACTERS
^KT-59996 Fixed
2023-10-31 22:04:06 +00:00
Marco Pennekamp 50fdc2128f [AA] Improve documentation of ProjectStructureProvider.getModule
- Since this documentation was written, the usages of contextual modules
  have expanded beyond outsider files, for example to support `KtModule`
  disambiguation for library elements. Hence, it was necessary to update
  the documentation accordingly.
2023-10-31 17:34:44 +00:00
Kirill Rakhman ac203591e5 [FE, Java resolve] Support inheritors of sealed Java type without permits clause
This fixes a false negative NO_ELSE_IN_WHEN in K2 and incidentally
also fixes a false positive NO_ELSE_IN_WHEN in K1 since the fix is in
the common code.

#KT-62491 Fixed
2023-10-31 13:41:56 +00:00
Svyatoslav Kuzmich 15d3bf5e25 [Wasm] Port JS interop type checker to K2 (KT-56849) 2023-10-31 12:34:32 +00:00
Dmitrii Krasnov 0c46cfd761 [Gradle MPP] Added duplicate source set name diagnostic
#KT-62601 Fixed
2023-10-31 12:34:14 +00:00
Mikhail Glukhikh 290adda8fc Calculate empty array literal types in FIR2IR instead of deserializer
This commit handles situations when some annotation in deserialized code
has an empty array literal argument [] or even non-empty [something].
Before this commit, we tried to guess a type of this array by "resolving"
the relevant annotation class and looking into the corresponding
parameter. Sometimes it can work, but also it can provoke recursive
resolve e.g. when the annotation class is a nested class in the same scope.
In this commit we changed the behavior in the following way:
- first, for non-empty array literals in deserialized code we just
take the array type from the corresponding array literal element
- second, for empty array literals we no more try to "guess" anything.
Instead we approximate array type as Array<Any>, and later at FIR2IR
stage we use the corresponding parameter type instead. At FIR2IR stage,
everything is already resolved and problems with recursions are no more
possible.

#KT-62598 Fixed
2023-10-31 12:30:29 +00:00
Mikhail Glukhikh 19a95f2fb4 K2: swap heuristics in AnnotationLoader (related to KT-62598)
Before this commit, we first tried to guess a type of array literal
in deserialized annotation (it's a strange heuristics which can
lead to SOE and maybe not needed at all, see KT-62598, KT-62929),
and then, if unsuccessful, took the type from the first literal element,
if any. Since the second heuristic is much more clear, safe, and
understandable, in this commit they were swapped.

This commit does not fix KT-62598 in general case,
but decreases a set of cases when it can occur to
empty array literals only.
See the commented line at the end of the added test.
2023-10-31 12:30:29 +00:00
Ilya Kirillov 4720a0faa7 [Analysis API FIR] fix NPE of == call resolve without builtins
We should not expect builtins to be always available as they are taken from indecies.

For K1 and FIR Standalone implementations, the builtins are always available.

^KT-62957 fixed
2023-10-31 12:24:16 +00:00
Ilya Kirillov 1aa5cf031f [Analysis API FIR] fix "ConeClassLikeTypeImpl is not resolved to symbol for on-error type"
We should not expect builtins to be always available as they are taken from indecies.

For K1 and FIR Standalone implementations, the builtins are always available.

^KT-62010 fixed
2023-10-31 12:24:16 +00:00
Nikolay Lunyak f5d859f209 [FIR] Don't miss smartcast info on equalities with when subjects
Since they are not `FirSmartCastExpression`s,
they are treated as proper original types,
thus leading to reporting errors instead of
warnings.

^KT-60095 Fixed
2023-10-31 10:40:43 +00:00
Alexander Udalov 4f96171716 K2: report IR_WITH_UNSTABLE_ABI_COMPILED_CLASS
Also, remove setting the value of allowUnstableDependencies to true if
K2 is used because we want K2 to report errors (as K1 does) on
unstable-ABI dependencies.

 #KT-61598 Fixed
2023-10-31 10:39:43 +00:00
Alexander Udalov 6a1c210cd1 Minor, remove obsolete mention of issue in previously muted test
The test was fixed for K2 in 365ce2a6a5.
2023-10-31 10:39:43 +00:00
Brian Norman 01a757cbd6 [FIR] Report PROPERTY_WITH_NO_TYPE_NO_INITIALIZER for all properties
Currently, PROPERTY_WITH_NO_TYPE_NO_INITIALIZER is reported for local
variables, but not reported for member or top-level properties. Add a
check to the common `checkPropertyInitializer` for when a property
type cannot be determined from the getter.

This also corrects a K1 versus K2 inconsistency, where K2 would allow
blocks from getters to determine property type instead of only allowing
expression bodies.

^KT-59935 Fixed
^KT-60117 Fixed
^KT-60123 Fixed
2023-10-30 16:28:10 +00:00
Anton Lakotka b154283149 [Gradle] Make sure that rootSoftwareComponent is always added
Even when createDefaultMultiplatformPublications=false and maven-publish
is applied it is required to create all publication-specific entities
such as tasks, configurations, components etc. In order to let users
to compose publications on their own.

^KT-62877 Verification Pending
2023-10-30 16:11:38 +00:00
Anton Lakotka d3f25d81de [Gradle] Change withPluginId to isPluginApplied
It is more convenient to use.
Also added test coverage for cases when plugin is applied too late.

^KT-62877 Verification Pending
2023-10-30 16:11:38 +00:00
Anton Lakotka 5607ae1bc3 [Gradle] Extract publicationDelegate as Project Stored Property
Previously it was attached to RootSoftwareComponent which has
heavy initialization work, for instance it creates new configurations
upon creation. The `publicationDelegate` is used in
`idOfRootModule` and should not trigger RootSoftwareComponent
initialization. After the change `idOfRootModule` became cross-project
safe. I.e. Project `foo` can call `idOfRootModule` on project `bar`.

^KT-62877 Verification Pending
^KTIJ-27374 Verification Pending
2023-10-30 16:11:38 +00:00
Anton Lakotka 6bb33cc8bc [Gradle] Test for Project's collection mutation after evaluation
Mutating projects data, particularly, adding new items to its
collections such as tasks, configurations and components is a potential
risk to lose these data during the import to IDE.

^KT-62877 In Progress
2023-10-30 16:11:38 +00:00
Sebastian Sellmair 36d1622276 [Gradle] Mute IdeNativeStdlibDependencyResolver in case of missing stdlib 2023-10-30 10:40:34 +00:00
Alexander Korepanov 0d7de87e2e [JS IR test] Add a test for invalidation with a src name chash 2023-10-30 09:14:16 +00:00
Alexander Korepanov ec71fe20e2 [JS IR] Fix file name clashes during JS BE invalidation 2023-10-30 09:14:16 +00:00
Alexander Korepanov 73bf7fa506 [JS IR test] Add a simple multiplatform invalidation test 2023-10-30 09:14:15 +00:00
Alexander Korepanov bf80d55fc3 [JS IR test] Use relative paths for klib building in invalidation tests 2023-10-30 09:14:15 +00:00
Alexander Korepanov 27b458c222 [JS IR test] Support multiplatform for invalidation tests 2023-10-30 09:14:15 +00:00
Evgeniy.Zhelenskiy 756cd25417 [FIR] Support typed projections in exposed visibility declaration checker
#KT-62925
2023-10-30 07:22:34 +00:00
Evgeniy.Zhelenskiy a836e6bf29 [FIR] Support flexible types and star projections in exposed visibility declaration checker
#KT-62925
2023-10-30 07:22:34 +00:00
Teng Zhang bf86afc867 KT-57870: Suppress InvalidPathException for paths with invalid characters when loading Konan library
^KT-57870 Fixed
2023-10-30 07:03:55 +00:00
Nikolay Lunyak d694c5d219 [FIR] Add references to the related K1 functions 2023-10-30 06:58:40 +00:00
Nikolay Lunyak cb4183bec6 [FIR] Remove enforcesEmptyIntersection
It's confusing + it's not really
correct. It checks properties of
LUB types rather than the original
ones, but if we want to replicate
K1, we should check the originals.
2023-10-30 06:58:40 +00:00
Nikolay Lunyak ed8935899c [FIR] Relax incompatibleEnumAndUnrelatedInterface 2023-10-30 06:58:40 +00:00
Nikolay Lunyak 8ec7d128f5 [FIR] Add one more missed case 2023-10-30 06:58:40 +00:00
Nikolay Lunyak 3fb7407ca1 [FIR] Make FirEqualityCompatibilityChecker a bit more readable 2023-10-30 06:58:40 +00:00
Nikolay Lunyak c6bec2fa75 [FIR] Relax incompatibleEnumAndUnrelatedInterfaceThroughTypeParameter 2023-10-30 06:58:40 +00:00
Nikolay Lunyak 3058f2eaff [FIR] Relax incompatibleEnumComparisonWithTypeParameters 2023-10-30 06:58:40 +00:00
Nikolay Lunyak ae521524d6 [FIR] Add tests highlighting false errors in K2 regarding equalities
Some overlooked corner-cases found by Denis.
2023-10-30 06:58:39 +00:00