Commit Graph

105077 Commits

Author SHA1 Message Date
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
Nikita Bobko e8630fd63f ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker: error -> warning
^KT-62263 Fixed
Review: https://jetbrains.team/p/kt/reviews/12401/timeline
2023-10-05 10:36:38 +00:00
Aleksei.Cherepanov a32c65e4e1 Convert absolute to relative pluginsClasspath..
..to avoid recompilation on build with portable caches

#KT-62256 Fixed


Merge-request: KT-MR-12377
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2023-10-05 10:25:53 +00:00
Vladimir Sukharev 7b3e661776 [FIR] Fix Disappeared ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT
^KT-59942 Fixed
2023-10-05 10:18:09 +00:00
Mikhail Glukhikh c860de6600 Use bootstrapped Native bundle with pre-release ON to fix Gradle tests
Related to KT-62058
2023-10-05 09:58:29 +00:00
Mikhail Glukhikh 52010e38e3 Temporarily mute failing tests around IS_PRE_RELEASE (related to KT-62058)
These tests should be fixed by bootstrapping
2023-10-05 09:58:29 +00:00
Mikhail Glukhikh 9bb1a0a31d LV 2.0: set KotlinCompilerVersion.IS_PRE_RELEASE to true
#KT-62058 Fixed
2023-10-05 09:58:29 +00:00
Svyatoslav Scherbina e22d9821e2 Native: fix kotlin-native/performance/framework build script for K2
The build script manually specifies which directories are parts of
which source sets. And it did that wrong: all directories were just
added to the nativeMain source set.
This was an incorrect configuration (matching expect and actual were
getting into the same source set), and K2 compiler was not really happy
with that.

This commit fixes the correspondence between source sets and source
directories in kotlin-native/performance/framework build script, thus
fixes the build for that benchmark with K2.
2023-10-05 09:17:58 +00:00
Svyatoslav Scherbina 4672727bd6 Native: enable K2 for benchmarks in performance/
Those benchmarks are built with bootstrap KGP and snapshot compiler.
Currently the former is K1, while the latter is K2. As a result, the
build fails because K2 compiler needs -Xfragment-sources argument,
while K1 uses -Xcommon-sources. So KGP passes the latter, while the
compiler expects the former.

Fix this by forcing KGP to use K2 for benchmarks in performance/
This can be reverted once bootstrap is updated to 2.0.0.
2023-10-05 09:17:58 +00:00
Nikolay Lunyak cca04bbcc2 [FIR] Check test text for all alongside tests
For some reason the practice is to configure the K2
diagnostics tests as "alongside" and instruct K1
tests to ensure there are no unexpected differences
in the sources. But someone may still forget there is
something that they need to configure in the K1 runners.
2023-10-05 08:46:54 +00:00
Mahdi Hosseinzadeh d803e0e31c Fix a grammatical issue in String::isNotBlank docs
"except of ..." is wrong.
Instead, it should be either of the following:
  - "except ..."
  - "except for ..."
  - "with the exception of ..."

See https://www.merriam-webster.com/dictionary/except%20for
and https://ell.stackexchange.com/q/148197
2023-10-05 03:56:05 +00:00
Brian Norman 365ce2a6a5 [FIR] Implement checker for missing dependency supertypes
#KT-60778 Fixed
2023-10-04 21:57:43 +00:00
Pavel Punegov a72eafc92b [K/N][test] Fix cache mode selection for test targets without cache
Execution of tests without cache support should be restricted. Such runs
should use default cache mode (without).
2023-10-04 19:21:51 +00:00
Vladimir Sukharev cd4c241fa3 [K/N] Run irText tests for K2/Native
^KT-58240
2023-10-04 18:20:05 +00:00
Stanislav Erokhin 0cfa721585 [KMP] Remove experimental from -Xmulti-platform flag
#KT-61686
2023-10-04 18:19:35 +00:00
Ilmir Usmanov e5aa737eaf Do not trim getType from com.intellij.lang.jvm.JvmParameter
Since K2 KAPT uses this API, absence of class bodies in classes
from the package leads to java.lang.NoSuchMethodError

 #KT-61879 Fixed
2023-10-04 17:15:05 +00:00
vishwajeet.barve 28fabf06fc Native: update README to reflect that build time depends on system configuration (#5189)
Co-authored-by: vishwajeet.barve <vishtech36@gmail.com>
2023-10-04 14:59:54 +00:00
Vladimir Sukharev 03442e1cee [FIR] Implement FirGenericArrayClassLiteralSupport platform feature
^KT-59931 Fixed
2023-10-04 14:45:23 +00:00
Vladimir Sukharev 9ab6353032 [FIR] Fix some Disappeared CLASS_LITERAL_LHS_NOT_A_CLASS
^KT-59931
2023-10-04 14:45:23 +00:00
Sebastian Sellmair 1dad890652 [Gradle][KMP] Remove top level and target level compilerOptions APIs
as those experimental APIs have shown to negatively affect usages
of stable APIs (because of resolve confusion), whilst also
failing to address popular use cases.

KT-61636
KT-61355
KT-61368
2023-10-04 12:23:39 +00:00
Artem Kobzar eef57f216c [K/JS] Rework main function call to support it in per-file 2023-10-04 12:13:20 +00:00
Roman Efremov faae5f9b38 [IR] Fix annotation arguments comparison when expression is expect enum
...actualized via typealias. This caused false-positive report of
`ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE`.
In such case it's incorrect to compare signatures, because classes have
different `ClassId`s. Instead, classes could be compared using
`areCompatibleExpectActualTypes` which actualizes both types, and
then enum value names compared.

^KT-62104
^KT-59940
2023-10-04 11:38:15 +00:00
Roman Efremov 67a46eba9c [FIR2IR] Fix default value conversion in annotation classes
This fixes failing test
`FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.DefaultArguments.testAnnotationsViaActualTypeAlias2`.

It started to fail after commit 4e08cafc78
"[FIR2IR] Get rid of IrSymbol.owner usages in Fir2IrLazyClass"
where in Fir2IrLazyClass `declarationStorage.getIrConstructorSymbol`
was changed to `declarationStorage.getOrCreateIrConstructor`.

Before change, value parameters were initialized in
`Fir2IrLazyConstructor#valueParameters` where
`forcedDefaultValueConversion` was passed.
After the change parameters via
`Fir2IrCallableDeclarationsGenerator.declareParameters` where
`forcedDefaultValueConversion` is not passed to method.

^KT-62104 Fixed
2023-10-04 11:38:15 +00:00
Roman Efremov 705b2e87fd Revert "[K2] Temporary mute ACTUAL_ANNOTATION_CONFLICTING_DEFAULT_ARGUMENT_VALUE"
This reverts commit b232dbf484.
2023-10-04 11:38:15 +00:00
Mikhail Glukhikh 8bd792792f K2: consider backing fields of vars as smartcast unstable
#KT-61974 Fixed
2023-10-04 10:12:57 +00:00
Mikhail Glukhikh 8e577e101e K2: reproduce KT-61974 2023-10-04 10:12:57 +00:00
Dmitry Savvinov 0d98995a8e [build] Fix regex in verification-metadata.xml for kotlin-native
Regex OR ('|') has weird precedence rules and previous version of regex
were essentially checking two alternatives:
- kotlin-native-prebuilt-.*-1\.9\.3[0-9](-.+)?
- 2\.0\.0(-.+)?

This is obviously incorrect, but it won't manifest on machines that
already downloaded that artifact to `.konan` via the build without
verification-metadata.xml
2023-10-04 10:04:07 +00:00
Timofey Solonin 8dc9307f9e Add iconv void * overloads for backwards compatibility
Since Xcode 15 the iconv APIs operate on an opaque type __tag_iconv_t* instead of
void*. This causes a runtime exception in older Ktor versions which
depended on iconv.

^KT-62286
2023-10-04 08:04:37 +02:00
Egor Kulikov 057973f4bb [FIR] Fix NPE on invalid gets with index
^KT-60342 fixed
2023-10-03 22:34:46 +00:00
Ivan Kochurkin 319fb967ec [FIR] Add TYPE_ARGUMENTS_FOR_OUTER_CLASS_WHEN_NESTED_REFERENCED diagnostics
Report TYPE_ARGUMENTS_FOR_OUTER_CLASS_WHEN_NESTED_REFERENCED instead of
WRONG_NUMBER_OF_TYPE_ARGUMENTS where it's appropriate

^KT-59393 Fixed

Simplify FirTypeResolverImpl
2023-10-03 19:49:56 +00:00
Ivan Kochurkin 8d27af5b0d [FIR] Fix reporting of TYPE_ARGUMENTS_NOT_ALLOWED instead of WRONG_NUMBER_OF_TYPE_ARGUMENTS 2023-10-03 19:49:56 +00:00
Ivan Kochurkin 42e5e43302 [FIR] Refactor FirTypeResolverImpl.resolveUserType
Fix IndexOutOfBoundsException on an attempt to cast an element

to inner class with type parameter

^KT-60921 Fixed
2023-10-03 19:49:56 +00:00
Ivan Kochurkin 5cd9afbf73 [FIR] Don't use @OptIn(LookupTagInternals::class) in DeclarationUtils 2023-10-03 19:49:56 +00:00
Svyatoslav Scherbina 8d82e7285d Bump Kotlin/Native version in KGP to 2.0.0-dev-4323 2023-10-03 17:49:16 +00:00