Commit Graph

106725 Commits

Author SHA1 Message Date
Nikita Bobko da8a8cc492 Revert "K2/Java: add private enum constructor for MPP matching"
Review: https://jetbrains.team/p/kt/reviews/13368/timeline

This reverts commit 2cea2b9098.

Motivation:
KT-62961 was fixed independently by two different commits:
- ac3d8ad3ac
- 2cea2b9098

If possible, it's better not to introduce implicit declarations.
That's why it was agreed to keep
ac3d8ad3ac and revert
2cea2b9098
2023-12-05 17:49:18 +00:00
Kirill Rakhman 8496722603 [FIR] Make UNSAFE_INFIX_CALL and UNSAFE_OPERATOR_CALL parameter nullable
This fixes an NPE in the IDE in presence of a syntax error when the
argument expression has no source.

#KT-64062 Fixed
2023-12-05 17:25:28 +00:00
Troels Bjerre Lund b059754f64 [K/N] LLVM: Transition to opaque pointers 2023-12-05 15:26:27 +00:00
Troels Bjerre Lund c1f72de6e5 [K/N] LLVM: Add missing opaque pointer API
LLVMConstGEP2 and LLVMConstInBoundsGEP2 were forward declared in
LLVM-11, but not implemented until LLVM-14. This patch adds these along
with the missing LLVMAddAlias2. All three implementations are copied
from llvm branch release/14.x
2023-12-05 15:26:27 +00:00
Nikita Bobko 61f825fbd4 [FIR] FirExpectActualDeclarationChecker: add assertions that sources are not null
We don't have "expect as libraries" feature yet. But once we have the
feature, the code in question might start silently behave incorrectly.

Add assertions to make sure that the code will fail
2023-12-05 14:12:20 +00:00
Alexander.Likhachev 209dbae893 [Daemon] Make daemon port validator more precise
Previously, the validation was that the port is within the [1, 65535) range. Considering the defined range [17001, 18000) for the random port selector, it makes more sense to check that range instead.
2023-12-05 13:51:14 +00:00
Alexander.Likhachev 2c8501eb10 [Daemon] Add unit tests for LastDaemonCliOutputsTest 2023-12-05 13:51:14 +00:00
Alexander.Likhachev 3ca1249926 [Daemon] Add unit tests for LimitedLinkedList 2023-12-05 13:51:14 +00:00
Alexander.Likhachev f7b139466d [Build] Move the daemon client sources into the default directory 2023-12-05 13:51:14 +00:00
Alexander.Likhachev d8c416f818 [Gradle] Replace the deprecated K/JS plugin in ExecutionStrategyIT.kt 2023-12-05 13:51:14 +00:00
Alexander.Likhachev b000b66ef7 [Daemon] Improve some daemon log messages
A few messages were improved:
  * If the daemon process died at the startup, add its last 10 lines of the output to the log and report to the EXCEPTION (ERROR in the case of Gradle) level
  * If some exception occurs during connection attempt, add its stacktrace and report to the EXCEPTION (ERROR in the case of Gradle) level
  * Added more DEBUG level messages
  * Some important messages are moved to the INFO level
  * Added a suggestion to report issue to kotl.in/issue
^KT-55322 Fixed
2023-12-05 13:51:14 +00:00
Alexander.Likhachev 95bc49054f [BT] Release daemon compile session right after compilation is finished
^KT-55322 In Progress
2023-12-05 13:51:14 +00:00
Alexander.Likhachev 3ccca58bb0 [Gradle] Release daemon compile session at a compilation task's finish
Before this change, some long-running tasks like `run` might cause the Kotlin daemon to go into the LastSession state and stay in that state until the long-running tasks and therefore the Gradle build are finished.
The reason for that behaviour is that if we don't release sessions explicitly, the created "session is alive" marker files are cleaned up by `KotlinGradleFinishBuildHandler.buildFinished` at the end of the build.
^KT-55322 In Progress
2023-12-05 13:51:14 +00:00
Alexander.Likhachev 8ceee3e8b9 [Daemon] Improve daemon connection algorithm
Before this change, the logic was to find the most suitable daemon and try connecting to it in a loop, ignoring the fact that it could be dying. Now, instead of trying to connect to the daemon dying daemon in a loop, we will make only 1 attemp and then skip if it's already dying.
^KT-55322 In Progress
2023-12-05 13:51:14 +00:00
Alexander.Likhachev 44d6807aba [Daemon] Fix deprecation warning in KotlinCompilerClient.kt 2023-12-05 13:51:14 +00:00
Alexander.Likhachev 3172e74a90 [Daemon] Apply autoformatting to ClientUtils.kt 2023-12-05 13:51:14 +00:00
Alexander.Likhachev 02b1f9854f [Daemon] Apply autoformatting to KotlinCompilerClient.kt 2023-12-05 13:51:14 +00:00
Alexander.Likhachev 628f6e981d [Daemon] Add test for KT-55322 2023-12-05 13:51:14 +00:00
Alexander.Likhachev b8d1398bdb [Daemon] Use JUnit Vintage engine to run JUnit4 tests 2023-12-05 13:51:14 +00:00
Nikita Bobko 2a7403a979 [FIR, IR] Run DefaultArgumentsInExpectActualizedByFakeOverride not only in FIR but in IR as well
Review: https://jetbrains.team/p/kt/reviews/13334/timeline

Thanks to the previous commit, it's now possible to run
DefaultArgumentsInExpectActualizedByFakeOverride on both: frontend (FIR)
and backend (IR).

We aim to perform a thorough examination of checks involving
fake-overrides on both FIR and IR, given their distinct implementations
for handling fake-overrides.

The commit decreases scope of influence of hacky
`shouldCheckDefaultParams` flag.
2023-12-05 13:30:14 +00:00
Nikita Bobko 1aeefe6c33 [FIR] Don't traverse expect hierarchy to check DefaultArgumentsInExpectActualizedByFakeOverride
^KT-63860 Fixed
Review: https://jetbrains.team/p/kt/reviews/13334/timeline

The previous code was nonsense (I wrote it). It doesn't make sense to
subtract actualOverriddenDeclarations from expectOverriddenDeclarations.
Default parameters are mentioned on the expect side. So default params
in expect/actual supertypes won't be subtracted from
expectOverriddenDeclarations (but should be)
2023-12-05 13:30:14 +00:00
Sergej Jaskiewicz d0f87f9aba [FIR/IR generator] Rename field's needAcceptAndTransform to isChild
This better describes the semantics.
2023-12-05 11:41:02 +00:00
Simon Ogorodnik 02052421e6 K2 Inference. Fix naming of locals to match its purpose
There were a number of locals where components of InitialConstraint were
named lower and upper in the FirBuilderInferenceSession.

That is not true for equality constraints, so such naming should be
avoided to avoid misconception about the nature of type relation encoded
in constraint.

^KT-64031 Fixed
2023-12-05 10:45:09 +00:00
Yahor Berdnikau b7d6cdb6eb [Gradle] Fix warning in GradleCompilationResults
^KT-56904 In Progress
2023-12-05 09:26:45 +00:00
Dmitriy Novozhilov c3fdbab7fe [FIR] Get rid of FirProvidedDeclarationsForMetadataService.getProvidedNestedClassifiers
It's now impossible to add new classes to metadata, because this
  functionality is not implemented in IrGeneratedDeclarationsRegistrar
  and FirDeclarationsForMetadataProviderExtension is removed
2023-12-05 10:21:40 +02:00
Dmitriy Novozhilov 139e1223ea [Serialization] Workaround registering static writeSelf method in metadata
`IrGeneratedDeclarationsRegistrar` assumes that all generated functions
  are correct from a Kotlin point of view. But `writeSelf` method on JVM
  is a static method outside any object/companion object

So to properly calculate containing class for this method we should
  generate a dispatch receiver parameter, register the method in metadata,
  and then remove the parameter (to make function static)
2023-12-05 10:21:40 +02:00
Dmitriy Novozhilov 51dcd7c076 [Serialization] Introduce utility for generation of IR annotation calls 2023-12-05 10:21:40 +02:00
Dmitriy Novozhilov c70c8f927e [FIR] Remove FirDeclarationsForMetadataProviderExtension extension
`IrGeneratedDeclarationsRegistrar` should be now used instead to register
  IR declarations in resulting metadata
2023-12-05 10:21:40 +02:00
Dmitriy Novozhilov d94ce4dcb8 [Serialization] Migrate to IrGeneratedDeclarationsRegistrar API
^KT-63591 Fixed
2023-12-05 10:21:39 +02:00
Dmitriy Novozhilov 159bc1b435 [IR] Introduce API to register generated IR declaration to be present in metatada
KT-63881
2023-12-05 10:21:38 +02:00
Dmitriy Novozhilov 1cdc8361d6 [IR] Rename IrAnnotationsFromPluginRegistrar to IrGeneratedDeclarationsRegistrar
In further commits, this service will be used not only for registering
  annotations, but newly generated IR declarations too
2023-12-05 10:21:27 +02:00
Simon Ogorodnik 751defc812 K2 Inference: Remove unreachable condition.
The condition was added to the substitute function, when it was also
re-used in delegate inference.
However, delegate inference no longer uses this function.
It is not very possible to both have variable fixed and being present in
nonFixedToVariablesSubstitutor in builder inference.

^KT-64028 Fixed
2023-12-04 21:56:03 +00:00
Simon Ogorodnik 2037714eec K2 Inference: Add doc to the substituteNonFixedToVariables function 2023-12-04 21:56:03 +00:00
Simon Ogorodnik 8bf7c30407 K2 Inference: Remove overloading of FirBuilderInferenceSession.substitute
There are two overloads of substitute function
in the FirBuilderInferenceSession.
In fact, it has very different usage and semantics.

Relates to KT-64028
2023-12-04 21:56:03 +00:00
Mikhail Glukhikh 1f989dce64 K2: add test for KT-56520, case (7), qualifier receivers (4.2)
This commit covers enum entry vs companion member case,
when two companion objects are in the scope.
K1 reports UNRESOLVED_REFERENCE here, probably due to ambiguity.
About K2, while resolving Some.foo it first tries to resolve Some
as a "general" variable access, and gets two candidates with companions.
After that it tries to resolve Some as a qualifier,
but we have no scope with a single qualifier, so no influence here.
With two ambiguous candidates with companions for Some,
OVERLOAD_RESOLUTION_AMBIGUITY is reported.
2023-12-04 21:50:46 +00:00
Mikhail Glukhikh 63ce4ba6b0 K2: add test for KT-56520, case (7), qualifier receivers (4.1)
This commit covers enum entry vs companion member case,
when one companion object is in the scope.
K1 reports UNRESOLVED_REFERENCE here, probably due to ambiguity.
About K2, while resolving Some.foo it first tries to resolve Some
as a "general" variable access, and gets the only candidate with companion.
After that it tries to resolve Some as a qualifier,
but we have no scope with a single qualifier, so no influence here.
Finally during foo resolve it should choose between enum entry and
companion member, and enum entry wins due to KT-37591.
2023-12-04 21:50:45 +00:00
Mikhail Glukhikh 76b2b9fc66 K2: add test for KT-56520, case (7), qualifier receivers (3)
This commit covers object vs static member case,
when no companion objects are in the scope.
K1 reports UNRESOLVED_REFERENCE here, probably due to ambiguity.
About K2, while resolving Some.foo it first tries to resolve Some
as a "general" variable access, and gets two erroneous candidates
without companions. After it tries to resolve Some as a qualifier,
but we have no scope with a single qualifier.
That's why we finally report NONE_APPLICABLE on candidates with companions.
2023-12-04 21:50:45 +00:00
Mikhail Glukhikh 602801dcfd K2: add test for KT-56520, case (7), qualifier receivers (2.2)
This commit covers object vs companion member vs static member case
but now we have two different companions (first is empty) in the scope.
K1 reports UNRESOLVED_REFERENCE here, probably due to ambiguity.
About K2, while resolving Some.foo it first tries to resolve Some
as a "general" variable access, and gets some/Some & some2/Some
because both of them have a companion. This means ambiguity.
After it tries to resolve Some as a qualifier, but we have no scope
with a single qualifier, so finally we prefer to report ambiguity
from variable access resolve.
2023-12-04 21:50:44 +00:00
Mikhail Glukhikh ab161333a7 K2: add test for KT-56520, case (7), qualifier receivers (2.1)
This commit covers object vs companion member vs static member case
in situation with only one companion in the scope.
K1 reports UNRESOLVED_REFERENCE here, probably due to ambiguity.
About K2, while resolving Some.foo it first tries to resolve Some
as a "general" variable access, and gets only some2/Some
because it has a companion. Then it tries to resolve Some as a qualifier,
but here we have an ambiguity, so finally Some with companion is preferred.
2023-12-04 21:50:43 +00:00
Mikhail Glukhikh c2ac9daa7f K2: add test for KT-56520, case (4), callable references (unbound)
Again, both frontends here ignored classifiers from
explicit star imported scope (some.HashMap, java.util.HashMap)
because of their ambiguity. In case of K2, it works so due to logic
in BodyResolveComponents.resolveRootPartOfQualifier.
This function is called to resolve qualifier without receiver.
See also cases (3) and (7).
2023-12-04 21:50:43 +00:00
Mikhail Glukhikh f0058ee0d8 K2: add test for KT-56520, case (4), callable references (bound)
In this test, things work in the similar way as in constructors case (2).
K1 resolves the explicit receiver HashMap<String, String>()
to kotlin.collections.HashMap /* = java.util.HashMap */.
K2 does the similar, but fun processConstructors from ConstructorProcessing.kt
makes a type alias substitution, so in fact constructor of expanded
java.util.HashMap is processed.

Pay attention that both frontends ignore some.HashMap and java.util.HashMap
due to ambiguous classifiers in explicit star importing scope.
See FirScope.processConstructorsByName in ConstructorProcessing.kt
2023-12-04 21:50:42 +00:00
Mikhail Glukhikh 168717b811 K2: add test for KT-56520, case (7), qualifier receivers (1)
Again, both frontends here ignored classifiers from
explicit star imported scope (some.HashMap, java.util.HashMap)
because of their ambiguity. In case of K2, it works so due to logic
in BodyResolveComponents.resolveRootPartOfQualifier.
This function is called to resolve qualifier without receiver
2023-12-04 21:50:42 +00:00
Mikhail Glukhikh 22d083a7a9 K2: add test for KT-56520, case (3), class literals
Again, both frontends here ignored classifiers from
explicit star imported scope (some.HashMap, java.util.HashMap)
because of their ambiguity. In case of K2, it works so due to logic
in BodyResolveComponents.resolveRootPartOfQualifier.
This function is called to resolve qualifier without receiver, in case
it's used as a receiver itself (::class counts as a selector equivalent).
2023-12-04 21:50:41 +00:00
Mikhail Glukhikh 6fb88102a5 K2: add test for KT-56520, cases (1), (5), (6), type references
In both these situations, we have some.HashMap & java.util.HashMap
from explicit star importing scope, and kotlin.collections.HashMap
from implicit star importing scope after it.
K1 ignores both explicitly imported classifiers due to their ambiguity,
and then resolves to kotlin.collections.HashMap at the next level.
In contrast, K2 takes explicitly imported classifiers and
properly reports ambiguity.
2023-12-04 21:50:40 +00:00
Mikhail Glukhikh d07f3a14e6 K2: add test for KT-56520, case (2), constructors, Space subcase
In this test, both frontends resolve to fun Semaphore.
Both work this way because interface/class Semaphore classifiers are
clashed (ambiguity) and ignored.
K2 reports ambiguity for some similar cases,
but constructor resolve still ignores ambiguous classifiers when found.
(see FirScope.processConstructorsByName in ConstructorProcessing.kt)
2023-12-04 21:50:40 +00:00
Mikhail Glukhikh 6049f8657b K2: add test for KT-56520, case (2), constructors
In this test, K1 resolves to kotlin.collections.HashMap /* = java.util.HashMap */
K2 does the similar, but fun processConstructors from ConstructorProcessing.kt
makes a type alias substitution, so in fact constructor of expanded
java.util.HashMap is processed.

Pay attention that both frontends ignore some.HashMap and java.util.HashMap
due to ambiguous classifiers in explicit star importing scope.
See FirScope.processConstructorsByName in ConstructorProcessing.kt
2023-12-04 21:50:39 +00:00
Sebastian Sellmair 0713866c1e [K/N] Modularise :kotlin-native:native.backend to extract objc header generation (2/2)
^KT-63905 Fixed
2023-12-04 18:52:08 +00:00
Sebastian Sellmair ae9f3d66c2 [K/N] Modularise :kotlin-native:native.backend to extract objc header generation (1/2)
^KT-63905
2023-12-04 18:52:08 +00:00
Nataliya.Valtman 4294c7bab7 Add limitation for changed files list for JPS build report
#KT-63549
2023-12-04 18:19:15 +00:00
Anton Lakotka 6eeb459076 [Gradle] Add defaultDestinationDir to FatFrameworkTask
To prevent cycle when updating destinationDirProperty
2023-12-04 18:08:09 +00:00