Commit Graph

109346 Commits

Author SHA1 Message Date
Wojciech Litewka e737320d01 [FIR generator] Specify Field.isChild in base tree configuration
instead of inside implementation configuration.

Whether a field is a child element is a core concept of the tree,
not a matter of particular implementation class.

It is especially visible in IR tree, where the base classes implement the
acceptChildren method. It will also be more relevant in the future.

This also aligns the config style between IR and FIR tree generators.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 6d5b07ebe9 [tree generator] Add AbstractElement#subElements, drop semantic leaves
The notion of IR element class being 'semantically leaf' is rather hacky.
Instead, now we only distinguish whether an element has its
implementation class, which is what this notion was actually trying to
represent.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 7e01fc5906 [IR] Drop "leaf/non-leaf" comment from generated IR classes
As it is not much useful, and the current wording does not represent its
intended wording.
2024-02-28 09:29:56 +00:00
Wojciech Litewka d904ce0939 [tree generator] Merge default and custom implementations 2024-02-28 09:29:56 +00:00
Wojciech Litewka 665bd5153a [tree generator] Make defaultEmptyList#withGetter false by default
to align it with other default* methods.

This will be helpful for configuring IR implementation,
where there are many such empty lists.
2024-02-28 09:29:56 +00:00
Wojciech Litewka 5d7a5245ff [tree generator] Extract printPropertyDeclaration util
analogous to printFunctionDeclaration.

This decouples the printing logic from handling IR elements' fields,
and makes it easier to directly print arbitrary fields.
2024-02-28 09:29:56 +00:00
Wojciech Litewka 92ff782815 [IR] Call IR declaration constructors with named parameters
When those classes become auto-generated, the order of constructor
parameters will differ.
This commit ensures they will still be resolved correctly.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka a005f2e75d [IR] Make IrFunction.returnType lateinit
to replace custom logic that would throw in case of IrUninitialized.

This is to remove custom logic from those classes,
so that source generator will be able to generate
them in a straight-forward way.
Otherwise, it would need to be thought about those special cases, which
is better to be avoided.

There are two consequences:
- The error message will be more generic, and won't contain reference
to the element.
- It becomes possible to reassign returnType
property with IrUninitializedType
and read it afterward.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 92c56d0535 [IR] Remove custom error messages for missing IrDeclaration.parent
This is to remove custom logic from those classes,
so that source generator will be able to generate
them in a straight-forward way.
Otherwise, it would need to be thought about those special cases, which
is better to be avoided.

It is also a small step for future work,
which likely involves making parent property nullable.

Unfortunately, this change causes a loss of some details from exception
messages.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka f6b2a5915e [IR] Remove some default values from implementation classes' constructors
To make it a bit easier and cleaner to autogenerate them.
Those default values were mostly unused anyway.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 2a5b4ae652 [IR] Remove files parameter from IrModuleFragmentImpl
This commit removes the default parameter in constructor,
as well as custom logic in this class, which would
make it harder for its subsequent auto-generation.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 83bc12949b [IR] Push default values from base to implementation classes
The default value of those properties is a detail that should be handled
 by implementation or builder layer.

 This change will also simplify auto-generating and reasoning about
 generated implementation classes, and allow for potential further
 enhancements like intercepting all mutations.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 5921706a15 [IR generator] Minor: split Model.kt into Element.kt and Field.kt
^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka fbd8c79c1b [IR] Change IrErrorClassImpl from object to property
to avoid subclassing IrClass, which is a bit problematic for
subsequent refactorings.
2024-02-28 09:29:56 +00:00
Wojciech Litewka daeea1747d [IR] Split files containing multiple Ir*Impl classes
To produce smaller diff when switching to auto-generated classes.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Wojciech Litewka 3d9194c82c [IR] Make IrMutableAnnotationContainer an IrElement
It is required, so that IR tree generator will properly handle
the `annotations` property in subsequent commits,
e.g., to include them in implementation classes.

All subclasses of IrMutableAnnotationContainer
do already derive from IrElement.

^KT-65773 In Progress
2024-02-28 09:29:56 +00:00
Mikhail Glukhikh 202c7f4677 K2: cleanup of FirVisibilityChecker.isVisibleForOverriding 2024-02-28 09:00:56 +00:00
Dmitriy Novozhilov dd94de3a34 [FIR2IR] Properly set statement origin for all parts of += calls
^KT-65649 Fixed
2024-02-28 08:28:14 +00:00
Dmitriy Novozhilov e4537cb9f0 [FIR2IR] Unify utilities for rethrowing exceptions with attachments 2024-02-28 08:28:14 +00:00
Dmitriy Novozhilov 88206ca151 [Util] Allow to use Throwable as cause of ExceptionWithAttachment 2024-02-28 08:28:14 +00:00
Dmitriy Novozhilov 5c632bc78e [FIR2IR] Don't create f/o symbols on smartcasted Nothing in dispatch receiver
^KT-63525 Fixed
2024-02-28 08:28:14 +00:00
Dmitriy Novozhilov 62e9c944fe [FIR2IR] Minor. Cleanup Fir2IrVisitor.convertToIrReceiverExpression 2024-02-28 08:28:12 +00:00
Dmitriy Novozhilov 5b01396a11 [FIR] Carefully process constructors of inner and nested classes in the tower
If there is an expression receiver, we should process constructors only
  of inner classes. Constructors of nested classes can be called only
  on classifier

^KT-65333 Fixed
2024-02-28 08:08:32 +00:00
Dmitriy Novozhilov 67557ce731 [Test] Reproduce KT-65333 2024-02-28 08:08:31 +00:00
Alexander Udalov 7f90111283 Build: remove obsolete -Xbuiltins-from-sources from stdlib build
It was removed in 77dba281a3.
2024-02-28 07:25:47 +00:00
nataliya.valtman 485840731d Remove old build report properties
kotlin.build.report.dir and kotlin.internal.single.build.metrics.file
were deleted

#KT-64380
2024-02-27 21:46:53 +00:00
nataliya.valtman a7f57710e2 Create checker for deprecated gradle properties
#KT-64380 Fixed
2024-02-27 21:46:52 +00:00
Abduqodiri Qurbonzoda 65cfc578a8 Introduce constructor-like function for AutoCloseable #KT-66102 2024-02-27 20:52:49 +00:00
Abduqodiri Qurbonzoda 557ea32f87 Introduce kotlin.AutoCloseable typealias in K/JVM stdlib #KT-55777 2024-02-27 20:52:49 +00:00
Abduqodiri Qurbonzoda 98ad68eb90 Promote AutoCloseable & use to stable #KT-65532 2024-02-27 20:52:49 +00:00
Marco Pennekamp 708ed81eb2 [Test] Avoid importing unused @Nested annotations in generated tests
- Unused `Nested` imports frequently cause unused import warnings in the
  IDE, which are especially annoying in after-commit warning/error
  analysis.
2024-02-27 20:30:06 +00:00
Abduqodiri Qurbonzoda 0811a5b77b Promote enumEntries() to stable #KT-65532 2024-02-27 19:49:12 +00:00
Artem Kobzar 02a78051aa [PSI2IR] Sync start and end offsets on PSI and FIR for an implicit return inside lambdas 2024-02-27 19:25:24 +00:00
Vladimir Sukharev a582bf22e3 [JS] Try remove ScriptRemoveReceiverLowering
^KT-64958
2024-02-27 19:10:03 +00:00
Aleksei.Glushko 69127b4483 [K/N] Exapnd concurrent part of the GC mark phase (KT-58865)
* Build mark closure completely concurrent.
    * Reintroduce concurrent weak processing.
    * Request the second STW only to preare the heap for sweeping.
2024-02-27 18:55:31 +00:00
Aleksei.Glushko b7067e0980 [K/N] ExtraSafePointActionActivator to be used in concurrnt mark 2024-02-27 18:55:31 +00:00
Aleksei.Glushko 728e9a5811 [K/N] OnceComputable C++ utility class 2024-02-27 18:55:31 +00:00
Anna Kozlova e650ba9855 [AA] return expect declaration for "implicit" actual
If actual declaration is broken (missing explicit `actual` keyword),
expect declaration still makes sense.
This way, we allow refactorings on broken code

^KT-65191 fixed
2024-02-27 18:49:02 +00:00
Ivan Kylchik 98dba48fde [Native] Simplify AssertRemovalLowering 2024-02-27 17:41:33 +00:00
Ivan Kylchik 6ec75a705e [IR] Store original function in the IrInlinedBlock
In Native and JS, there is a special logic where the compiler saves
a copy of inlined function (see `InlineFunctionsSupport`). This copy
is used in the IR inliner. Because of that, we can't really compare
inlined function with other functions directly. We need to
get `originalFunction` first and save it.
2024-02-27 17:41:33 +00:00
Artem Kobzar 800704a130 [K/JS] Allow private constructors inside external declarations ^KT-65964 Fixed 2024-02-27 16:51:07 +00:00
Marco Pennekamp aabb7aaa18 [LL] CleanableSoftValueCache: Make read/write action requirements bold
- This should improve the read/write action requirement visibility in
  the documentation.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 2b40ef6b05 [LL] CleanableSoftValueCache: Avoid cleanup on already removed values
- The cache guarantees deterministic cleanup on removal, so if the
  reference has already been removed from the cache, there is no need to
  clean it up again.
- Still, I don't want to guarantee that `SoftValueCleaner` is only
  invoked once (see its documentation), as soft reference semantics
  cannot be tested properly in our current test infrastructure.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp f7a0e1f7c1 [LL] CleanableSoftValueCacheLincheckTest: Check cleanup state of removed values
- Now it's checked that cleanup behaves as expected in a concurrent
  setting for `put` and `remove`. Note that Lincheck never checks that a
  value is actually cleaned up. Instead, it compares the result with the
  single-threaded execution of a scenario. Hence, the non-concurrent
  `CleanableSoftValueCacheTest` is crucial, as it separately ensures
  correct deterministic cleanup in a single-threaded environment.
- We cannot test that operations returning a new value (such as `get`)
  always return values which haven't been cleaned up yet, because the
  value might be cleaned up by another thread between the return point
  of the operation and cleanup checking.

^KT-62136
2024-02-27 16:45:52 +00:00
Marco Pennekamp d4b0dfee0a [LL] Update Lincheck to version 2.24
- This new version fixes problems with concurrent hash maps in model
  checking tests and allows us to remove the correctness guarantee for
  them.

^KT-62136
2024-02-27 16:45:52 +00:00
Marco Pennekamp 5207940f0b [LL] CleanableSoftValueCache: Add non-concurrent tests for value cleanup
- The non-concurrent `CleanableSoftValueCacheTest` ensures that
  deterministic cleanup behaves correctly. A Lincheck test can only
  discover differences between the single-threaded and concurrent
  executions of a test scenario, so it cannot find correctness issues
  with deterministic cleanup on its own.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 53e545aa3f [LL] CleanableSoftValueCache: Don't perform cleanup when putting the same value
- If we have some value `X` in the cache, and we put `X` a second time
  into the same location, `X` shouldn't be cleaned up because it wasn't
  actually removed from the cache.
- With this feature, it's necessary to implement `put` in terms of
  `backingMap.compute`, because we need to compare the old and the new
  value atomically, and based on that, decide whether to create a new
  soft reference.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 80a2382cf6 [LL] Add Lincheck tests for CleanableSoftValueCache
- Lincheck tests the linearizability of a concurrent data structure,
  which helps us verify that `CleanableSoftValueCache` works in
  concurrent scenarios.

^KT-62136 fixed
2024-02-27 16:45:52 +00:00
Marco Pennekamp b2cd29726b [LL] Rewrite CleanableSoftValueCache in terms of ConcurrentHashMap.compute
- The previous implementation of `putIfAbsent` made two calls to the
  `backingMap`: `putIfAbsent` and `replace`. This breaks atomicity at
  least in theory. Implementing the major compute operations in terms of
  `backingMap.compute` allows us to restrict the critical section to
  this single atomic `ConcurrentHashMap` operation, which is easier to
  reason about.
- Using `backingMap.compute` also improves the guarantees we can make in
  respect to `computeIfAbsent`'s computation function `f`. We can now
  guarantee that the function is called exactly once iff the `key` is
  absent, because it is only ever invoked inside `backingMap.compute`,
  which makes this guarantee itself.
- Remove `putIfAbsent`, which isn't currently used by
  `LLFirSessionCache`. It can easily be implemented using
  `computeIfAbsent` in the future.

^KT-61222
2024-02-27 16:45:52 +00:00
Marco Pennekamp 5819f4eaa2 [LL FIR] Test resolve extension disposal after modification events
- These tests simply ensure that a resolve extension is disposed after
  any kind of modification event is raised. It's not meant to test
  complex scenarios, but rather to detect when resolve extension
  disposal isn't invoked *at all*.
- I tried implementing a similar test for resolve extension disposal
  after soft reference garbage collection, but the only way to force the
  GC to collect soft references is to allocate memory until an
  out-of-memory error occurs. That is bad for the test infrastructure,
  because it might allocate A LOT of memory (depending on the max heap),
  which is problematic for running tests locally. Also, our Kotlin tests
  stop on an OOM error altogether (so additional configuration would be
  required) and the heap is dumped into a 20GB file (on my machine),
  which is again problematic for local test runs.

^KT-61222
2024-02-27 16:45:52 +00:00