Commit Graph

105875 Commits

Author SHA1 Message Date
Nikita Bobko 24e74487d6 [FIR] Fix DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE tests
This commit fixes the following tests:
    FirOldFrontendMPPDiagnosticsWithPsiTestGenerated
        DefaultArguments
            MethodDefaultArgsViaActualFakeOverride
                testIntersectionOverride
                testSimple
                testDelegation
                testSubstitutionOverride
                testSimpleIncompatible

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:21 +00:00
Nikita Bobko 76ffbcc67c [IR] Update testData ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
After previous commits, IrExpectActualAnnotationMatchingChecker reports
errors even if the declaration is incompatible but matched

We had a duplicated diagnostic in other cases before my commits, anyway.
it will be fixed in
https://youtrack.jetbrains.com/issue/KT-62559/KMP-K2-prevent-reporting-ACTUALANNOTATIONSNOTMATCHEXPECT-twice-in-CLI#focus=Comments-27-8293687.0-0

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:20 +00:00
Nikita Bobko 8722e142f6 [IR] 2/2 Propogate expect-actual checker incompatibilities to IR backend
Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:20 +00:00
Nikita Bobko eb0c8c00c3 [FIR, IR] 1/2 Minimize usages of ExpectActualCompatibility, MismatchOrIncompatible and MatchedOrCompatible
- Migrate ExpectActualCompatibility -> ExpectActualCheckingCompatibility
  where the "checker" is expect
- Migrate ExpectActualCompatibility -> ExpectActualMatchingCompatibility
  where the "matching" is expect

KT-62590 in progress. A lot of tests start to fail now. I will fix them
in next commits

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:19 +00:00
Nikita Bobko 664b9cc3ba [FIR, IR] ClassScopes incompatibility: split unfulfilled incompatibilities into "mismatchedMembers" and "incompatibleMembers"
KT-62590 is in progress

Unfortunatelly, ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT is now reported
twice in 'classScopeViaTypealiasIncompatible' test.

We had a duplicated diagnostic in other cases before my commits, anyway.
it will be fixed in
https://youtrack.jetbrains.com/issue/KT-62559/KMP-K2-prevent-reporting-ACTUALANNOTATIONSNOTMATCHEXPECT-twice-in-CLI#focus=Comments-27-8293687.0-0

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:19 +00:00
Nikita Bobko d0b34fe378 [FIR, IR] Refactor: restructure ExpectActualCompatibility class hierarchy
KT-62590 is in progress

This commit is pure refactoring.
- No tests changed their behaviour
- Semantics isn't changed

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:18 +00:00
Nikita Bobko bbbc775181 [FIR, IR] Drop code that don't belong to AbstractExpectActualMatcher
- The Matcher must only do the "matching" (aka "strong compatibility")
- Drop all "checking" related (aka "weak compatibility" related) logic
- `checkClassScopesCompatibility` parameter belongs to the
  "expect-actual checker" not to the "expect-actual matcher". Drop it

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:18 +00:00
Nikita Bobko 1c6e529146 [FIR, IR] Rough split of AbstractExpectActualCompatibilityChecker into matcher & checker
This commit:
1. renames AbstractExpectActualCompatibilityChecker to AbstractExpectActualChecker
2. `cp compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualChecker.kt compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualMatcher.kt`
   + rename the object in AbstractExpectActualMatcher.kt
3. KDocs

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:17 +00:00
Nikita Bobko 4ef8595a4b [IR] Don't check class scopes compatibility in collectActualCallablesMatchingToSpecificExpect
This is a minor optimization.
This commit is a step forward for KT-62590

Conceptually, `checkClassScopesCompatibility` belongs to the
"expect-actual checker". It doesn't belong to the "expect-actual
matcher".

- `checkClassScopesCompatibility` should be set to `true` when you want
  to do the "checking"
- `checkClassScopesCompatibility` should be set to `false` when you want
  to do the "matching"

`collectActualCallablesMatchingToSpecificExpect` only needs the
"matching"

No tests changed their behaviour

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:17 +00:00
Nikita Bobko a3401b2f9e Minor: cleanup + support variance in ErrorListDiagnosticListRenderer
1. Support variance in ErrorListDiagnosticListRenderer.
   I will make some diagnostics to have covariant type arguments in the
   next commits
2. Drop unused code

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:17 +00:00
Nikita Bobko 3b47610817 [FIR] Refactoring: "Move in" parentSubstitutor creation to getCallablesCompatibility
Motivation: Make getCallablesCompatibility API slightly nicer. The
function is going to be called from more places after KT-62590 is fixed.
This commit makes fixing KT-62590 easier

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:16 +00:00
Nikita Bobko bc5180656d [FIR] ReturnType expect-actual incompatibility: convert from strong to weak
It should have been WeakIncompatible from the beginning because it's not
possible to overload by return type in Kotlin

This commit is a step forward to fix KT-62591

Unfortunately, the test cannot demonstrate the problem because of
another bug in K2 KT-59887

^KT-62752 Fixed
Review: https://jetbrains.team/p/kt/reviews/12750/timeline

Motivation:

It makes expect-actual matching-checking model more consistent.

expect-actual "matching" is run before FirResolvePhase.BODY_RESOLVE. You
can't know return types, until you run BODY_RESOLVE. That's why the
return type can't be checked during expect-actual matching. But it's
cursed: you have something that have to match by, but, at the same time,
you can't do it.

expect-actual "checking" is run after FirResolvePhase.BODY_RESOLVE.
That's why if we convert ReturnType incompatibility to WeakIncompatible
(which should have been called CheckingIncompatible), then expect-actual
matching model becomes consistent.

We will also be able to get rid of unnecessary
FirActualCallableDeclarationChecker. Because it won't be necessary.
Return types will be checked by common logic of expect-actual "checker"
2023-11-06 14:41:16 +00:00
Nikita Bobko e778ddfd21 [AA] getExpectForActual analysis-api now returns compatible or weakly incompatible
^KTIJ-27522 Fixed

It's the only reasonable behavior for this API in it's current shape
(when it returns a list of declarations)

It's a common mistake to take only Compatible from
expectActualMatchingMap. The problem will be gone after I fix KT-62590

Motivation to fix this bug, is because it will be easier for me to split
expect-actual matcher-checker-monster thing KT-62590

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:15 +00:00
cristiangarcia 69c209874d Use cache-redirector to download Node.js for js.tests 2023-11-06 11:01:54 +01:00
Sergej Jaskiewicz a84277782a [IR generator] Don't use kotlinpoet for auto-generating IrFactory
KT-61970
2023-11-06 09:47:22 +00:00
Anton Lakotka ebe0a84dee [Gradle] Fix GCC support for IOS specific Kotlin Native Test Tasks
^KT-63044 Verification Pending
2023-11-06 09:37:59 +00:00
Anton Lakotka 704adc053a [Gradle] Test native tasks with Gradle 8.4 Configuration Cache
^KT-63044 In Progress
2023-11-06 09:37:59 +00:00
Anton Lakotka 096cb0abce [Gradle] Add Gradle.G_8_4 version for tests 2023-11-06 09:37:59 +00:00
Alexander Udalov 4fca52b66c FIR entrypoint: deduplicate some code and remove JVM dependency
Deduplicate Fir2IrExtensions creation and move the
convertToIrAndActualizeForJvm function to 'cli', which allows to remove
the dependency of 'fir.entrypoint' on 'backend.jvm'.

Note that behavior slightly changes in IncrementalFirJvmCompilerRunner:
previously the value of linkViaSignatures was always false, now it is
taken from the compiler configuration, which seems more correct.
2023-11-06 08:49:04 +00:00
Dmitriy Novozhilov 420fbad73d [FIR2IR] Properly insert implicit casts to extension receiver in case of intersection smartcast type
^KT-62863 Fixed
2023-11-06 06:50:35 +00:00
Mikhail Glukhikh 50106c740c K2: reproduce situation from KT-62863 2023-11-06 06:50:35 +00:00
Mikhail Glukhikh 168b3416ea FIR2IR: avoid redundant implicit cast creation
Related to KT-62544
2023-11-06 06:50:35 +00:00
Mikhail Glukhikh ba06af9d7f FIR2IR: extract implicitCast function 2023-11-06 06:50:35 +00:00
Mikhail Glukhikh 1ef0f9e944 K2: reproduce strange "smartcast aside" behavior related to KT-62544 fix 2023-11-06 06:50:35 +00:00
Yahor Berdnikau 9c146adc3a [Gradle] Update stable Kotlin version to 1.9.20 in Duckduckgo benchmark 2023-11-05 16:40:07 +01:00
Yahor Berdnikau 8429ab0309 [Gradle] Update stable Kotlin version to 1.9.20 in Kvision benchmark
Benchmark is not working as Kvision fails to assemble with Kotlin 2.0:
- https://youtrack.jetbrains.com/issue/KT-62036
- https://youtrack.jetbrains.com/issue/KT-63094 (main issue)
2023-11-05 16:40:00 +01:00
Yahor Berdnikau 43dd155f59 [Gradle] Update stable Kotlin version to 1.9.20 Graphql-kotlin benchmark 2023-11-05 16:39:44 +01:00
Ilya Chernikov 65d1c8ce7e K2 Scripting: do not report import resolution errors on implicit imports
since implicit imports are used in the gradle scripts, where it seems
difficult to precisely control list of import to avoid
unresolved names. And we can relatively safely ignore
unresolved imports there

#KT-62404 fixed
2023-11-03 21:54:23 +00:00
Ilya Chernikov 02dc3c4ddb K2 Scripting: add annotation resolving for scripts
#KT-62400 fixed
2023-11-03 21:54:23 +00:00
Ilya Chernikov 31f9e9e7a8 K2 Scripting: implement basic metadata serialization support
#KT-62305 fixed
NB: kotlin reflection do not see script class constructor after
this change, and it's ok, since the fact that the script is compiled
into a class is an implementation detail.
If needed, java reflection could be used to access the constructor.
2023-11-03 21:54:23 +00:00
Ilya Chernikov 122f16fc18 K2 ignore return type on special java funs overrides
#KT-62197 fixed
2023-11-03 18:32:05 +01:00
Alejandro Serrano Mena 312187dbe6 [IR] Improve error messages for constant evaluation error 2023-11-03 14:54:48 +00:00
Brian Norman 1bb5e97b62 [FIR] Improve performance of missing supertype detection
^KT-62619 Fixed
2023-11-03 13:28:02 +00:00
Florian Kistner c55dc2578a Fix missing KonanManglerDesc in kotlin-backend-native-for-ide 2023-11-03 13:16:19 +00:00
Ilya Goncharov c2e2572680 [Gradle, JS] Use only KotlinJsCompilation
^KT-41382 fixed
2023-11-03 12:04:11 +00:00
Nikolay Lunyak b8e2a17de1 [Test] Fix diagnostics arguments rendering when quotes are present
Non-capturing `(?:)` was now needed to avoid
getting an additional group that only
contains the last symbol before the closing `"`.

^KT-62711 Fixed
2023-11-03 08:14:28 +00:00
Sergej Jaskiewicz 54de11cb58 [FIR/IR generator] Generate kDocs for visitor classes 2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz 570422dbd4 [FIR/IR generator] Print visitor method expression bodies on new line
This helps to avoid long lines in visitor classes.
2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz c5f519f7c7 [FIR/IR generator] Commonize visitor printing logic
This is a step towards commonizing the code generator between
FIR and IR: KT-61970

Also, don't use kotlinpoet for generating IR visitors (KT-61703)
2023-11-02 23:05:18 +00:00
Anna Kozlova 205a125c5f [AA] implement KtFirSimpleNameReference.getImportAlias
^ KT-62980 fixed

Merge-request: KT-MR-12786
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-11-02 21:23:43 +00:00
Vladimir Sukharev 0fb853a995 [FIR] Fix Disappeared CONTRACT_NOT_ALLOWED
https://youtrack.jetbrains.com/issue/KT-60004/K2-Disappeared-CONTRACTNOTALLOWED

Merge-request: KT-MR-12613
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-11-02 20:47:05 +00:00
Ilya Kirillov 834927a901 [Analysis API Standalone] fix common code analysis against a klib
^KT-63007 fixed
2023-11-02 19:19:39 +00:00
Dmitriy Dolovov a3bfe58415 [KLIB tool] Fix failing test on dumping c-interop signatures 2023-11-02 18:44:14 +00:00
Dmitrii Gridin 38524f6b15 [LL FIR] correctly calculate lazy bodies for delegated properties
We should rebind symbols from generated constructions to the original
ones as we already did for regular bodies like (PsiRawFirBuilder.bindFunctionTarget).
This commit also removed bodies for generated accessors as a bonus

^KT-61491 Fixed
2023-11-02 18:39:04 +00:00
Dmitrii Krasnov 680455b162 [FUS Tests] Changed expected hash in module changes
It changed in b9090e12 commit without updating it into the test

#KT-62987 Fixed
2023-11-02 15:25:19 +01:00
Brian Norman 6cf76e1d07 [FIR] Report no return diagnostic on functions returning Nothing
Previously, the NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY diagnostic was not
reported at all on functions which return Nothing. However, in K1, if
the function returns Nothing but the body is empty or doesn't contain a
Nothing expression, this diagnostic would be reported. The checker in K2
has been updated to report this diagnostic on functions which return
Nothing as well.

^KT-55965 Fixed
2023-11-02 13:20:55 +00:00
Sebastian Sellmair 3fb415d966 [Gradle] Replace KotlinTargetWithTestsConfigurator with KotlinTestRunFactory
KT-61634
2023-11-02 13:20:38 +00:00
Sebastian Sellmair 40820e42a6 [Gradle] Implement ConfigureBuildSideEffect (replacing 'configureBuild')
KT-61634
2023-11-02 13:20:38 +00:00
Brian Norman 5676759287 [FIR] Set thisReceiver when generating IrClass for unknown classes
^KT-60942 Fixed
2023-11-02 12:50:23 +00:00
Kirill Rakhman 2d7cadc0ab [FE, Java Resolve] Filter out canonical record constructors
This fixes a false positive overload resolution ambiguity in FIR
when invoking a record constructor when it also defines a canonical
constructor (compact or explicit).

#KT-62151 Fixed
2023-11-02 12:39:45 +00:00