Commit Graph

103657 Commits

Author SHA1 Message Date
Dmitrii Gridin b0b2e76e13 [LL FIR] dependent analyze: support different numbers of statements
Previously, the different number of statements has led to
some unexpected behavior. E.g., the resulting script can have
duplicated declarations – one from the original script instead of
some statement and one from the copy

^KT-60987
2023-08-10 16:18:26 +00:00
Dmitrii Gridin 4f4b30ee28 [LL FIR] dependent analyze: add test on different statements in script
It contains a wrong result. Will be fixed in the next commit

^KT-60987
2023-08-10 16:18:26 +00:00
Dmitrii Gridin 201100db60 [LL FIR] AbstractDependentCopyTest: supports custom text in copy
This provides an ability to test more real-world cases.
E.g., we can emulate completion behavior

^KT-60987
2023-08-10 16:18:26 +00:00
Nikita Bobko 52f0f75175 [FE] Cleanup: rename areXyzCompatible -> getXyzCompatibility
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

Motivation:
- Functions with prefix "are" must return Boolean. And
  AbstractExpectActualCompatibilityChecker even already contains some
  functions with prefix "are" that return Boolean (e.g.
  `areCompatibleCallableVisibilities`,
  `areCompatibleSupertypesOneByOne`, etc)
- Unification with functions that are prefixed with "are" and return
  Boolean
2023-08-10 15:46:48 +00:00
Nikita Bobko d4758014ec [FE] Type-safety refactoring: Make areCompatibleClassScopes to return Incompatible.WeakIncompatible
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

For StrongIncompatible `actual` declaration is considered as overload
and error reports on expected declaration. For WeakIncompatible the
error is reported straight away

Before the refactoring `areCompatibleClassScopes` returned just
`Incompatible`. It is bad because StrongIncompatible isn't possible for
classes (classes can't be overloaded). Now all class incompatibilities
are weak.

The commit has a minor impact on observable behavior (cases where we
reported the compilation problems are still reported but on another
elements):
- We no longer report type parameter class incompatibilities on expect
  declaration, we report them only on actuals (it happened because all
  WeakIncompatible are reported only on actuals)
- In a sense, Java implicit actualization was the only way to "overload"
  classes (it would be a redeclaration compilation problem, so it
  doesn't count as a valid "overload"). And since type parameters
  incompatibility was StrongIncompatible for classes, we counted them as
  "overloads" and didn't report incompatibility problems on Kotlin
  class. Now we do report. (see
  implicitJavaActualization_multipleActuals)
2023-08-10 15:46:48 +00:00
Nikita Bobko 98ec13b51a [FE] Type-safety refactoring: extract main logic of areCompatibleCallables into two functions
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

Extract main logic of `areCompatibleCallables` into two functions:
`areStrongIncompatibleCallables` and `areWeakIncompatibleCallables`.

The main point is that `areStrongIncompatibleCallables` &
`areWeakIncompatibleCallables` have very specific return types.

This commit doesn't change any logic. The commit makes the API more
type-safe ensuring that bugs like in previous commit (KT-60902) won't
happen again
2023-08-10 15:46:48 +00:00
Nikita Bobko eac4b81b11 [FE] Fix TypeParameterUpperBounds incompatibility priority
^KT-60902 Fixed
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

We should prioritize to return STRONG incompatibilities over WEAK
incompatibilities. But this invariant broke in `areCompatibleCallables`,
because `areCompatibleTypeParameters` returns incompatibilities of both
types, and `areCompatibleTypeParameters` is called in WEAK
incompatibilities section.

The fix is to split `areCompatibleTypeParameters` into two functions:
`areStrongIncompatibleTypeParameters` and
`areWeakIncompatibleTypeParameters`. And call each of this function in
appropriate `areCompatibleCallables` sections.
2023-08-10 15:46:47 +00:00
Nikita Bobko fd5e97ff23 [FE] Refactoring: Move check for "enumConstructorsAreAlwaysCompatible" higher than check for callable kind
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

This is a preparation refactoring for the following KT-60902 fix and
type-safety refactoring.

This commit doesn't have observable side effects (and can be called pure refactoring) because the following conditions:
1. `expectDeclaration is ConstructorSymbolMarker && actualDeclaration is ConstructorSymbolMarker`
2. `expectDeclaration is FunctionSymbolMarker != actualDeclaration is FunctionSymbolMarker`

can't be both `true` at the same time
2023-08-10 15:46:47 +00:00
Nikita Bobko 529a1dd720 Force recompile all call-sites of ExpectedActualResolver.{findActualForExpected, findExpectedForActual}
This is needed to workaround broken incremental compilation in JPS in
Kotlin plugin. The incremental compilation bug is reported KT-60759

In Kotlin plugin I created the same commit which changes the name of the
function on the call-site.

Review: https://jetbrains.team/p/kt/reviews/11039/timeline

After a few days in master branch, I will revert this commit
2023-08-10 15:46:46 +00:00
Nikita Bobko d39755b578 [FE] Convert specific diagnostic for actual function with default arguments into a common incompatibility
^KT-59665 Fixed
Review: https://jetbrains.team/p/kt/reviews/11039/timeline

It's better to have this logic in common place
(AbstractExpectActualCompatibilityChecker) to avoid missing compilation
errors in the future

This commit fixes:
1. Missing compilation error for actual function with default arguments
   for 'actual typealias' KT-59665
2. Missing compilation error for actual function with default arguments
   for actual fake-override KT-59665

Alternative solution for KT-59665 is to create a special checker.

"incompatibility" vs "special checker":

Arguments for common incompatibility:
- What if we had a rule that expect and actual default params must
  match? If so then it certainly would be an incompatibility.
- Technically, we do the matching of expect and actual params (because
  we allow default params in common ancestors of expect and actual
  declarations).
- It's hard to check that the actual definition doesn't use default
  params because `ExpectedActualResolver.findActualForExpected` filters
  out fake-overrides and doesn't return them. It's not clear logic for
  me, that I'm afraid to touch.
  implicitActualFakeOverride_AbstractMap.kt test breaks if you drop this
  weird logic
- WEAK incompatibilities can be considered as "checkers". So it doesn't
  matter how it's implemented, as a "incompatibility" or a "checker"

Arguments against common incompatibility:
- Although we match expect and actual declarations to allow default
  params in common ancestors of expect and actual declarations, it's
  still can be considered that we check that the actual declaration
  doesn't have default params. And it doesn't feel right that we check
  correctness of the actual declaration in expect-actual matcher.
- ~~It may change the rules of expect actual matching~~ (It's not true,
  because ActualFunctionWithDefaultParameters is declared as WEAK
  incompatibility)
2023-08-10 15:46:46 +00:00
Nikita Bobko ab8913dee8 [FE] Cover "implicit actualization"/"actual fake-overrides" KT-58544 with regression tests
Review: https://jetbrains.team/p/kt/reviews/11039/timeline
2023-08-10 15:46:45 +00:00
Alexey Merkulov e4ae15b3f0 [FIR] Allow resolve to private members from debugger evaluator
KT-60714
2023-08-10 13:40:52 +00:00
Alexey Merkulov 1714fb71c8 Tests: check errors from code fragment resolution 2023-08-10 13:40:52 +00:00
Nikolay Lunyak b7d1298f20 [FIR] Report UNSUPPORTED_SEALED_FUN_INTERFACE
^KT-59957 Fixed
2023-08-10 13:36:43 +00:00
Dmitriy Dolovov 8be98da1d3 [PL] Halt compilation when there are linkage issues logged with the ERROR severity
^KT-61097
2023-08-10 13:21:34 +00:00
Alexander Shabalin 288163437d [K/N] Remove legacy MM runtime modules ^KT-59121 2023-08-10 13:20:41 +00:00
Nikolay Lunyak f6e9e9379d [FIR] Drop redundant TODOS
It was decided to do so in the
corresponding tickets.

^KT-59828 Declined
^KT-59821 Declined
2023-08-10 12:55:03 +00:00
Denis.Zharkov 1eb0c606da Add clarification comments to some shouldKeepTypeVariableBasedType impls
^KT-61090 Related
2023-08-10 12:54:09 +00:00
Alexander Shabalin 6b50d0a44f [K/N] Make GC scheduler pausing less aggressive ^KT-61091 2023-08-10 11:21:30 +00:00
Ilya Gorbunov ca7e494124 Remove redundant dependency checksums
They are no longer resolved due to alignment
2023-08-10 10:35:54 +00:00
Ilya Gorbunov aaa068596c [Gradle] Disable stdlib-jdk7/8 alignment from 1.9.20
Reason: kotlin-stdlib now publishes Gradle metadata with the required dependency constraints for these artifacts

KT-55297
2023-08-10 10:35:54 +00:00
Ilya Gorbunov 0882c645dd [stdlib-mpp] Move dependency constraints to api dependencies, KT-55297
Constrained alignment is also required for compile time dependencies
2023-08-10 10:35:54 +00:00
Dmitrii Gridin 5d336e8649 [FIR] typeFromCallee: do not leak code 2023-08-10 10:35:21 +00:00
Mark Mann 8a31e2ed82 [IR] Optimize a few hot spots to reduce total CPU time
^KT-61121
2023-08-10 09:57:06 +00:00
Alexander Shabalin 83a70ddf8b [K/N] Decouple ObjectFactory from concrete ObjectData ^KT-60928
* Use type_layout to declaratively express heap object headers in both
  custom allocator and ObjectFactory.
* Invoke constructor (w/o invoking Kotin constructors) for created
  objects and arrays from both custom allocator and ObjectFactory.
  Previously:
  - custom allocator only checked body for nullability (now this is
    performed in body constructor)
  - ObjectFactory only constructed ObjectData
* In each GC have a AllocatorImpl.hpp and ObjectData.hpp headers
  the first encapsulating allocator-specific types, the second
  containing specific ObjectData implementation.
* In each GC have a separate ObjectFactoryTraits that does not
  actually depend on the specific GC anymore.
* Each GC now expose ObjectData (as undefined type) and its descriptor,
  the latter being used by the custom allocator and ObjectFactory.
* Descriptors for ObjectBody and ArrayBody now live in Memory.h and the
  code calculating size is now shared. Their constructors check that the
  memory is zeroed (Kotlin constructors will expect this).
2023-08-10 07:58:27 +00:00
Alexander Shabalin d956a5504d [K/N] Add a helper for objects with custom layout ^KT-60928 2023-08-10 07:58:27 +00:00
Nikolay Lunyak 70e98c9c2b [FIR] Report inherited java members referencing FunctionN
^KT-60000 Fixed
2023-08-10 05:14:08 +00:00
Ilya Chernikov 0c35e97a8d Tests: fix testLightTreeReadLineEndings
- it is now depends on the propery configured environment
2023-08-09 23:58:51 +00:00
Mikhail Glukhikh 0abf17201f K2: fix implementation of EXTENSION_PROPERTY_MUST_HAVE_ACCESSORS_OR_BE_ABSTRACT
This commit fixes
`FirCompileKotlinAgainstCustomBinariesTest.testUnreachableExtensionVarPropertyDeclaration`.
2023-08-09 23:58:51 +00:00
Alexander Udalov 54c7466074 Tests: add CompileKotlinAgainstCustomBinariesTest for K2
This is needed because after changing default language version to 2.0,
we still need to test many scenarios from this test in K1.

Move K1-specific tests to OldCompileKotlinAgainstCustomBinariesTest, and
K2-specific tests to FirCompileKotlinAgainstCustomBinariesTest.

Mute failing K2 tests via `muteForK2`. It will throw exception if the
muted test will suddenly start passing.
2023-08-09 23:58:51 +00:00
Alexander Udalov 21c7325dbe Tests: remove actualTypealiasToCompiledInlineClass test
This test uses multiple features which are obsolete and will be
discontinued soon:
- Language version 1.4
- Expect/actual declarations in the same module
- Declaring inline classes via "inline class"
2023-08-09 23:58:51 +00:00
Alexander Udalov bad7fa597b Tests: move some tests to diagnostics 2023-08-09 23:58:51 +00:00
Alexander Udalov b3b9ffaea9 Tests: remove obsolete txt dumps in CompileKotlin...Test
Check that the client code compiles against the "broken" classpath
instead. Descriptor text dump is a part of the obsolete test
infrastructure and should not be used anymore.
2023-08-09 23:58:50 +00:00
Alexander Udalov 19abb66886 Tests: minor cleanup in CompileKotlinAgainstCustomBinariesTest
Fix inspections, formatting
2023-08-09 23:58:50 +00:00
Alexander.Likhachev 2675531624 [Build] allow empty build cache url to disable it
4af1970b28 allows it only for the included build
2023-08-09 22:10:43 +00:00
Nikolay Lunyak a871fa9a64 [FIR] Don't ignore too many diagnostics
`DelegatingConstructorCall` -
because in this case there is
either `UNRESOLVED_REFERENCE` or
`SYNTAX` already.

`ErrorTypeRef` - because in this
case there is `SYNTAX` already.
Note that there is only 1 test
that shows this behavior, and
it's LT-specific. It's
`FirLightTreeOldFrontendDiagnosticsTestGenerated.testKt847`, and
in this test the string template
is parsed and processed
differently in LT and PSI:

- in LT there are 6 nodes: "",
"$this", " must be", "$as", "$t",
"".
- in PSI there 4 notes: "$this",
" must be", "$as", "$t".
2023-08-09 21:00:06 +00:00
Alexander Korepanov 7a31167e0b [Common IR] Do not add internal methods to overrides
[JS IR] Use a module name in JsFunctionSignature for internal methods

^KT-60635 Fixed
2023-08-09 16:35:59 +00:00
Anna Kozlova 788fa5d545 [psi] skip absent parameter names in function type presentation
KTIJ-26566
2023-08-09 16:29:37 +00:00
Svyatoslav Scherbina 05d38c8297 Native: don't build tests/samples/echoServer on Windows
Because of KT-50547, this test doesn't work on Windows with HMPP
enabled.

Previously, because of that HMPP was disabled for all samples.
But now disabling HMPP is no longer possible, so ce9a45b enables HMPP
for samples.

Disable echoServer sample on Windows to workaround ^KT-50547
2023-08-09 16:22:14 +00:00
Dmitrii Gridin bdd8cce69c [LL FIR] LowLevelFirApiFacadeForResolveOnAir: drop unused function 2023-08-09 15:22:57 +00:00
Dmitrii Gridin 3947ba57da [LL FIR] support on-air resolve for scripts
We should reanalyze only statements and leave declarations as they are

^KT-61013 Fixed
2023-08-09 15:22:57 +00:00
Dmitrii Gridin 4c8399ae8c [LL FIR] KtToFirMapping: encapsulate recorder
We need this to avoid wrong recorders in on-air resolve

^KT-61013
2023-08-09 15:22:57 +00:00
Dmitrii Gridin d19a23aae5 [LL FIR] implement tests on dependent copy session analyze
^KT-60987
2023-08-09 15:22:57 +00:00
Dmitrii Krasnov 682cb991b8 Test for PartialLinkageMode resolving fix
#KT-60839 Fixed
2023-08-09 15:13:24 +00:00
Dmitrii Krasnov 1f61a195a9 Bump Kotlin/Native version in KGP to 1.9.20-dev-9320 2023-08-09 15:13:24 +00:00
Aleksei.Cherepanov c8c3565a24 Fix JPS import
Exclude kotlin-stdlib-js project for JPS build. Related to KT-56106

#KT-61059 Fixed


Merge-request: KT-MR-11527
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2023-08-09 14:37:21 +00:00
Margarita Bobova affe0754bf Add ChangeLog for 1.9.0 and move ChangeLog for 1.8.X to a separate file 2023-08-09 12:26:03 +00:00
Dmitriy Dolovov da2e6d93ff [Native][tests] Don't use trove4j in K/N new test infra 2023-08-09 12:15:39 +00:00
Svyatoslav Scherbina ce9a45bf92 Native: enable HMPP in tests/samples
Remove `kotlin.mpp.hierarchicalStructureSupport=false`.
Disabling HMPP is not supported anymore.

^KT-59304
2023-08-09 12:14:13 +00:00
Ilya Goncharov 949e4be658 [Gradle, JS] Add test with cross modules with compose dependency 2023-08-09 11:45:58 +00:00