Commit Graph

105110 Commits

Author SHA1 Message Date
Ivan Kochurkin 89fe73f6f4 [FIR] Consider expect default function parameters in FirSuperCallWithDefaultsChecker
^KT-61572 Fixed
2023-10-06 12:29:01 +00:00
Ivan Kochurkin ec5fd02ab9 [FIR] Enable FirSuperCallWithDefaultsChecker for Native
It's enabled for JVM and Native in K1
2023-10-06 12:29:01 +00:00
Evgeniy.Zhelenskiy feed3a57d0 [FIR] Report wrong modifiers in function type arguments and types of value parameters
#KT-59955
2023-10-06 12:22:57 +00:00
Nikita Bobko 43c97077eb 2/2 Extract K1 KMP matcher in its own subsystem. Fix compilation errors 2023-10-06 11:41:22 +00:00
Nikita Bobko cc70f78027 1/2 Extract K1 KMP matcher in its own subsystem. Copy files
This commit is literally this shell command:
```
cp compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualAnnotationMatchChecker.kt compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/K1AbstractExpectActualAnnotationMatchChecker.kt
cp compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualCompatibilityChecker.kt compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/K1AbstractExpectActualCompatibilityChecker.kt
cp compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualCollectionArgumentsCompatibilityCheckStrategy.kt compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/K1ExpectActualCollectionArgumentsCompatibilityCheckStrategy.kt
cp core/compiler.common/src/org/jetbrains/kotlin/resolve/multiplatform/ExpectActualCompatibility.kt compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/K1ExpectActualCompatibility.kt
cp compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/K1ExpectActualMatchingContext.kt
cp core/compiler.common/src/org/jetbrains/kotlin/resolve/multiplatform/ExpectActualMemberDiff.kt compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/K1ExpectActualMemberDiff.kt
```

Motivation: KMP is going to evolve in K2 a lot. But we don't want to
touch K1 version of KMP. That's why it's easeir to just copy-paste
expect-actual matcher into K1 flavor
2023-10-06 11:41:22 +00:00
Dmitrii Gridin 96c45c74e8 [LL FIR] improve contract violation checks
Add check into LLFirModuleLazyDeclarationResolver to die fast
and avoid StackOverflowError for jumping phases

^KT-56551
^KT-57802
^KT-57811
2023-10-06 11:40:05 +00:00
Ilya Kirillov 0fb3c033e7 [Analysis API FE10] introduce an exception which marks some parts of the Analysis API as not supported for K1 2023-10-06 11:39:33 +00:00
Ilya Kirillov 9dcd142f0d fixup! [Analysis API] implement an API to get a substitution based on a inheritance relationship between classes 2023-10-06 11:39:33 +00:00
Ilya Kirillov 8f6b3d37b9 fixup! [Analysis API] implement an API to get a substitution based on a inheritance relationship between classes 2023-10-06 11:39:33 +00:00
Ilya Kirillov 15e4cbc10d [Analysis API] implement an API to get a substitution based on an inheritance relationship between classes
^KT-62090 fixed
2023-10-06 11:39:33 +00:00
Ilya Kirillov 49cfbb0576 [Analysis API] remove duplicating logic for building KtSubstitutor by ConeSubstitutor 2023-10-06 11:39:33 +00:00
Ilya Kirillov 1107e728a2 [Analysis API] implement better rendering for chained KtSubstitutor 2023-10-06 11:39:33 +00:00
Ilya Kirillov e2d248b76d [FIR] extract functionality to a public function to use from Analysis API
^KT-62090
2023-10-06 11:39:33 +00:00
Pavel Kunyavskiy a561a8e531 [K/N] Improve the exception message in code generator exceptions
^KT-62335
2023-10-06 11:39:03 +00:00
Ilya Gorbunov 7bdcaff89a KT-61126 Change test expectations
Also improve failure diagnostics in test
2023-10-06 00:46:08 +00:00
Ilya Gorbunov 785d6858ea KT-62004 Drop legacy JS build of kotlin-stdlib
- preserve kotlin-stdlib-js.jar in dist and maven
- change packaging to klib in .pom
- fix manifest attributes of kotlin-stdlib-js
2023-10-06 00:46:08 +00:00
Ilya Gorbunov 6d5b1f84f9 KT-62004 Publish kotlin-dom-api-compat only for JS IR consumers 2023-10-06 00:46:08 +00:00
Ilya Gorbunov 2590e7f48b KT-62004 Add kotlin-test maven artifacts to BOM integration test 2023-10-06 00:46:08 +00:00
Ilya Gorbunov eb813b7837 KT-62004 Drop legacy JS build of kotlin-test 2023-10-06 00:46:08 +00:00
Evgeniy.Zhelenskiy 291d52820c [Reflection] Use reference equality to determine that a callable reference is bound
It helps to avoid problems when receiver object implements structural equals violating the equality contract

#KT-60709
2023-10-05 22:16:39 +00:00
Ilya Kirillov 64f90f685d [Analysis API] create declarations from a library with library origin in StubBasedFirDeserializedSymbolProvider 2023-10-05 17:01:40 +00:00
Ilya Kirillov a3b67594ff [FIR] add more information to ISE "Status should be resolved for a declaration to create it fake override" exception
^KT-62268
2023-10-05 17:01:40 +00:00
Ilya Kirillov 68c7673cb3 [Analysis API FIR] fix ISE "Status should be resolved for a declaration to create it fake override"
on calling completion on an instance of `kotlin.Pair`.

Caused by unresolved status for `copy` created for data classes from a library.

^KT-62268 fixed
2023-10-05 17:01:40 +00:00
Ilya Kirillov 5d769bf524 [Analysis API] add possibility to have different results for standalone/ide Analysis API mode in tests 2023-10-05 17:01:40 +00:00
Pavel Kirpichenkov 80832ddae1 [K2, JS] Don't fail on missing JS module kind service in IDE
There's no module kind check for IDE at the moment: IDE modules don't
have access to compiler arguments or configuration. K1 currently doesn't
report the diagnostic either. See KTIJ-27279 for more details.

This commit repeats K1 behaviour: K2 IDE won't fail because of the
missing service, but the diagnostic won't be reported in IDE, only
during compilation.

KT-61615
2023-10-05 15:50:35 +00:00
Anna Kozlova da385210d8 [AA] provide psiType#asKtType conversion
it's useful for IDE's features such as write UAST or refactorings

^KT-62302 fixed

Merge-request: KT-MR-12414
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-10-05 15:18:55 +00:00
Artem Daugel-Dauge 62544ec9c8 [Gradle] Don't copy DSYM in embedAndSign task
^KT-62232 Verification Pending
2023-10-05 14:40:15 +00:00
Vladimir Sukharev fa4de48d0e [FIR2IR] Create annotations for IrConstructor
^KT-62262 Fixed
2023-10-05 14:37:13 +00:00
Vladimir Sukharev e342d7ff66 [K/N] Revert language version override for uikit sample
^KT-62262
2023-10-05 14:37:13 +00:00
Vladimir Sukharev 520983d52c [K/N] Add failing test for KT-62262: NPE compiling uikit sample
^KT-62262
2023-10-05 14:37:13 +00:00
Brian Norman 2e6dbbe020 [FIR] Completely unwrap original argument when computing type arguments
When computing the conversion type for a type operator call, the
argument needs to be fully unwrapped before getting the resolved type.
This avoids the situation when the argument is a when-subject and the
assumed original type is not correct. Before, only smart-casts were
unwrapped, and this change will also unwrap when-subjects (as well as a
few other FirExpressions).

^KT-62114 Fixed
2023-10-05 14:12:06 +00:00
Brian Norman 23bdfd226f [FIR] Complete data-flow analysis for all control-flow graph nodes
There are conditions where the data-flow analysis for a control-flow
graph node is delayed. Make sure that when completing a graph, all nodes
within the graph have completed their data-flow analysis.

^KT-61794 Fixed
2023-10-05 13:41:45 +00:00
Troels Bjerre Lund f2fb237212 [K/N] Lower amount of finalization in stress test 2023-10-05 13:18:20 +00:00
Troels Bjerre Lund 239f3a30cb [K/N] Add flag to disable allocator overhead estimate 2023-10-05 13:18:20 +00:00
Troels Bjerre Lund 3ae7b790a9 [K/N] Update HeapTest
This adds TypeInfo to the objects allocated in HeapTest, which is now
needed by SweepObject to gather problem live set statistics.
2023-10-05 13:18:20 +00:00
Alexander Shabalin 2a41b80373 [K/N] Make stress_gc_allocations tests more useful ^KT-61914 2023-10-05 13:18:20 +00:00
Troels Bjerre Lund bb195749c8 [K/N] Re-enable mutator assist
Also remove disabling of GC scheduling during GC
2023-10-05 13:18:20 +00:00
Troels Bjerre Lund a752d5d000 [K/N] Estimate allocator overhead
This increases the boundary for the next GC scheduling by how much is
estimated is currently being wasted by the allocator due to paging. This
is necessary, since the gc scheduling boundary is set based on the size
of the live set at the last GC, while the current memory use is only
tracked in whole allocator pages. This patch avoids some of the
situations where the GC would be triggered again immediately upon
completion, which happens with many sparsely filled pages.
2023-10-05 13:18:20 +00:00
Troels Bjerre Lund fc13dbdb91 [K/N] Track live size on sweep
After the change to track allocations in big chunks (KT-57773), the
scheduler no longer had information about how much of the allocated
memory was used on live objects, which lead to a lot of extra memory
usage (KT-61914). This patch adds the tracking of live objects size to
sweeping, which is enough to mitigate the problem.

co-authored by Alexander Shabalin

^KT-61914
2023-10-05 13:18:20 +00:00
marat.akhin 968c116ecd [K2] Do not report CONFLICTING_OVERLOADS for hidden callables.
This makes sense as such callables do not conflict on their use-sites,
because a hidden callable loses to a non-hidden one when doing
overload resolution.

We achieve this by not considering such callables as conflicting when
collecting them in FirDeclarationCollector.
A callable is hidden if it will be hidden from the overload resolution,
meaning it has a `Deprecated` or `DeprecatedSinceKotlin` annotation.

NB: this also impacts `REDECLARATION` diagnostic for properties, as they
can also be marked as `Deprecated`.

NB: this change ignores local callables, as they are ignored
w.r.t. `Deprecated` in K2.

^KT-22004 Fixed
2023-10-05 13:10:34 +00:00
Alexander Udalov 8e7e24cc31 Remove reference to fixed issue in test data
These two tests are now failing with IR fake override builder because
e.g. the fake override `MyMutableList.foo` has two overridden symbols:
`MyList.foo` and `MyMutableCollection.foo`, as opposed to the normal K2
mode which only has the former.

This seems to only affect the printed IR dump. Note that in K1 there
were two overridden symbols as well.
2023-10-05 12:37:55 +00:00
Alexander Udalov 91d6d79cfa IR: remap reflectionTarget in FakeOverrideRebuilder 2023-10-05 12:37:55 +00:00
Alexander Udalov a80e1e2d09 IR: minor refactoring in FakeOverrideRebuilder
Extract the common logic of remapping fake overrides into a function.

Also, slightly change behavior of the check to be stricter: now it's
using `as S?` instead of `as? S`, which means that if the remapped
symbol is present in `fakeOverridesMap`, then it must be of the same
type.
2023-10-05 12:37:55 +00:00
Mikhail Glukhikh 4da7453a7b Add comment to TypeSystemCommonSuperTypesContext.checkRecursion
Related to KT-38544, KT-60581
2023-10-05 12:17:17 +00:00
Mikhail Glukhikh aea7b8f00a Common supertypes: unwrap captured type from DNN type during recursion control
This commit handles subtle situation when K1 represents flexible type
arguments as just T..T?, but K2 does it as T&Any..T?.
This can provoke a type like Captured(*)&Any..Captured(*)?,
and before this commit we couldn't find recursion inside Captured(*)&Any.
This could lead to explosions inside type system and inference errors

#KT-60581 Fixed
2023-10-05 12:17:17 +00:00
Mikhail Glukhikh 610a9d9c6a K2: reproduce KT-60581 2023-10-05 12:17:17 +00:00
Brian Norman 1add296388 [FIR] Unwrap dispatcher type when determining property stability
If the modality of a property is not final, the modality of the dispatch
receiver can be used to determine if the property is stable. When
looking up the dispatch receiver symbol, make sure to unwrap the lower
bounds of flexible types.

^KT-61735 Fixed
2023-10-05 12:09:55 +00:00
Mikhail Glukhikh 87904fd766 AbstractTypeChecker: don't create forks for identical supertypes
The main reason of this commit is the fact that it makes no sense
to create type checker forks in case of two or more types which equal
each other.

Also, this commit fixes the test taken from KT-59514
(see interconnectedGenerics.kt test changed in this commit).
In this particular case we have a subType of C.WithL<Pr!, En<Pr>!>,
and a superType of R<T> with a superType constructor R.
In findCorrespondingSupertypes we get *two* similar supertypes here,
both have a string representation of:
R<Il<@EnhancedNullability En<Pr>!>!>.
If we create two forks because of it, we get NEW_INFERENCE_ERROR
with the following subtyping violation:
Il<@EnhancedNullability En<Pr>!>! <: En<Pr>!.
NEW_INFERENCE_ERROR happens because we make a redundant fork in that case,
but the forks should still work despite it (see KT-62333).

These two types appear due to the content of FirCorrespondingSupertypeCache.
For a key C.WithL and a superType R it stores the following pair of supertypes:
- R<Il<@EnhancedNullability S>!>
- R<Il<(@EnhancedNullability S & Any, @EnhancedNullability S?)>!>
After substitution of S to En<Pr>! they become similar.
NB: if we change jspecify severity level from strict to warn,
then 'R<Il<(S & Any, S?)>!>' is the only remaining supertype,
and @EnhancedNullability annotation is no more in use.

The type hierarchy in this example looks like:
WithL<T, S> <: CanWithB<T, S>, R.F<S, Il<S>>
CanWithB<T, S> <: R.F<S, Il<S>>
R.F<S, Il<S>> <: R<Il<S>>

So R is reachable by two different ways, via CanWithB and directly via R.F.

#KT-59514 Fixed
2023-10-05 11:29:18 +00:00
Mikhail Glukhikh d4ec088afe K2: add reproduction for KT-59514 2023-10-05 11:29:18 +00:00
Hung Nguyen 4e89dcf031 [IC] Refactor IC maps to reuse code and ensure consistency
The key changes include:
  - Top interface: `PersistentStorage`
  - Implementation:
      + `LazyStorage`
      + `InMemoryStorage`
  - Extended functionality:
      + `BasicMap`
      + `PersistentStorageAdapter`

 The remaining changes are small cleanups to adapt to the above key
 changes.

 Test: Existing tests (refactoring change)
 Bug: N/A (code cleanup)
2023-10-05 11:12:25 +00:00