Commit Graph

4970 Commits

Author SHA1 Message Date
Kirill Rakhman 1876c8a9ee [AA] Fix getKtExpressionType for augmented array assignment
This previously worked on accident because the get call in an
augmented array assignment wouldn't have a resolved argument list, and
so `argumentsToSubstitutedValueParameters` would return null.
Now, we additionally verify that we're in a `set` call.

#KT-66124
2024-03-13 17:05:48 +00:00
Kirill Rakhman 8443daf78d [FIR] Remove FirNamedArgumentExpressions during completion
They are mostly necessary for argument mapping during resolution.
To support a couple checkers, we transform named args for varargs
into "fake" spread expressions.

Other than that, named arguments aren't needed for anything and often
lead to bugs where we forget to unwrap them for something, so it's
better to get rid of them.

#KT-66124
2024-03-13 17:05:48 +00:00
Kirill Rakhman 03fc0fd381 [FIR] Remove FirLambdaArgumentExpression
It's not really necessary if the information about if the lambda was a
trailing lambda can be directly saved in FirAnonymousFunctionExpression.

Removing the FIR node uncovered a couple of bugs
(UNINITIALIZED_ENUM_ENTRY, ERROR_IN_CONTRACT_DESCRIPTION) that were
caused by assuming that a lambda is always a trailing lambda.

#KT-66124
2024-03-13 17:05:48 +00:00
Ivan Kylchik 61fabc02ba [K2] Resolve bodies of const properties during IMPLICIT_TYPES_BODY_RESOLVE
This is required to implement constant evaluator on the FIR level.

#KT-64151
2024-03-13 16:53:59 +00:00
Ivan Kylchik 0ebf2862a9 [K2] Add new tests on lazy resolve to check new resolve rules
In the consequent commits, there are some changes in FIR resolve.
These tests will show the difference.

#KT-64151
2024-03-13 16:53:59 +00:00
Roman Golyshev 1884a655c5 KT-66498 [AA] Provide KDoc for isSubClassOf and isDirectSubClassOf 2024-03-13 16:31:41 +00:00
Roman Golyshev c6e442c18b KT-66498 [AA] Do not consider a class to be a subclass of itself in K1 impl for isSubClassOf
^KT-66498 Fixed
2024-03-13 16:31:41 +00:00
Roman Golyshev de75297875 KT-66498 [AA] Add more tests for the isSubClassOf/isDirectSubClassOf
Also, reproduce the difference between the K1 and K2 implementation
of `isSubClassOf` for the same class
2024-03-13 16:31:41 +00:00
Mikhail Glukhikh d6e67e43f9 K1/K2: add a test for KT-62866 2024-03-13 14:57:34 +00:00
Mikhail Glukhikh 3b9e08d6b8 K1/K2: reproduce KT-65789 2024-03-13 14:57:33 +00:00
Roman Efremov 284d5437e5 [FIR] Don't transform call arguments during TYPES phase
Instead, it should happen during BODY_RESOLVE phase.

This fixes KT-66150. The problem was, that `super<B>.f()` expression
in delegated constructor call was transformed during TYPES phase,
and type transformer has no special logic for allowing bare types in
super qualifiers, like the one in expressions transformer (see
`org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirExpressionsResolveTransformer.transformSuperReceiver`).
As a result, `B` without type argument leads to
WrongNumberOfTypeArgumentsError.
It looks incorrect that expressions in constructor call resolved
during TYPES phase, so skipping transformation of
argument list seems like the best solution here.

^KT-66150 Fixed
2024-03-13 14:31:14 +00:00
Roman Efremov c4f89ab32e [Test] Add test reproducing incorrect error in K2 about super qualifier
...with type arguments.
Also, add lazy resolve test to check the subsequent changes are correct.

^KT-66150
2024-03-13 14:31:14 +00:00
Kirill Rakhman 43a08068fc [Tests] Add regression tests for KT-32754
#KT-32754 Fixed
2024-03-13 12:39:54 +00:00
Alexander Udalov 55f9f74d5c Tests: do not report backend diagnostics if there's frontend error
In most affected tests, the backend diagnostic such as "conflicting JVM
signature" or "accidental override" is directly caused by some already
existing error reported by frontend, so it doesn't make sense to check
backend diagnostics there.

Tests where that was not the case were moved/copied to
`testsWithJvmBackend`.
2024-03-13 08:38:15 +00:00
Alexander Udalov dca6c21d7f Tests: remove duplicateJvmSignature diagnostic tests
All of these tests were actually copied to `testsWithJvmBackend` in
866f188120, but it's unclear why they were copied instead of moved. The
test runner for `testsWithJvmBackend` correctly runs the compiler
pipeline and obtains errors reported by the backend, as opposed to the
common diagnostic tests which have a very custom code, using parts of
the old JVM backend, to obtain these diagnostics.
2024-03-13 08:38:15 +00:00
Alexander Udalov 6ed06f4dac Tests: minor, move diagnostic test missingNames.kt
Looks like it was placed in the `duplicateJvmSignature` directory by
mistake.
2024-03-13 08:38:14 +00:00
Alexander Udalov 5be1ff1d5f Tests: minor, remove obsolete diagnostic tests
- `require.kt` was added to check JVM accidental override diagnostic
  when using the "traits with required classes" feature, which was
  removed a long time ago.
- `withErrorTypes.kt` was testing conflicting JVM declarations error (a
  backend diagnostic) in presence of error types -- not very useful
  scenario because the backend is not run when there's a frontend error.
2024-03-13 08:38:14 +00:00
Vladimir Sukharev 5fee662223 [Tests] Add test for KT-57391
^KT-57391
2024-03-12 18:10:10 +00:00
Nikolay Lunyak d3dfbec01a [FIR] Report warnings for inconsistent visibilities of accessors
K1 didn't report diagnostics for accessors
of intersection overrides, so this change
prevents a BC.

^KT-66046 Fixed
2024-03-12 16:35:05 +00:00
Nikolay Lunyak daa6e03e3b [FIR] Reproduce KT-66046
^KT-66046
2024-03-12 16:35:05 +00:00
Brian Norman c6c0abae82 [FIR] Create test case to validate KT-56988 is working as expected
^KT-56988 Fixed
2024-03-12 14:48:39 +00:00
Kirill Rakhman 973e337bf5 [FIR] Enhance getter overrides based on overridden properties
The following tests are failing with exceptions and will be fixed in the
following commits

j+k/testKjkPropertyAndExtensionProperty.kt
j+k/testKjkImplicitReturnType.kt

#KT-62118 Fixed
2024-03-12 10:29:45 +00:00
Kirill Rakhman 888cac6fc0 [Tests] Reproduce #KT-66048 2024-03-12 10:29:45 +00:00
Kirill Rakhman 29a9d3cdd9 [FIR] Fix copy paste error in receiver enhancement 2024-03-12 10:29:44 +00:00
Kirill Rakhman 8a90032e93 [FIR] Refactor deferred computation of callable copy return types
Rename some classes for clarity and move the implementations to the use
sites.
2024-03-12 10:29:43 +00:00
Vladimir Sukharev aa1cce78c3 [FIR] Incorrect warnings about inline function impact
^KT-65959 Fixed
2024-03-12 10:26:23 +00:00
Denis.Zharkov 141be17b4b K2: Add some more tests showing the state for KT-64840
lambdaParameterForBareTypeEarlyFixationAffectsBehavior.kt
should show in the future commits how early variable fixation
necessary for bare type information might affect inference results

^KT-64840 Related
2024-03-12 10:22:11 +00:00
Ivan Kylchik e1180adfbd [Native] Always cast expression to the expected type after inline
Right now, during the process of inlining, the compiler erases types.
Because of that, we can end up with some random type
(for example, `Any`) where the concrete type was
expected (for example, `Int`). Compiler must insert a cast in the
required places.

#KT-66017 Fixed
2024-03-12 08:19:50 +00:00
Dmitriy Novozhilov 7a383373b0 [Test] Reproduce KT-65415 and KT-66432 2024-03-12 06:46:09 +00:00
Dmitriy Novozhilov d352cc9d96 [Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
2024-03-12 06:43:58 +00:00
Marco Pennekamp 5dec87eba8 [LL] Use soft references in FileStructureCache
- We can also soft-reference the `KtFile` key. Chances are, if the
  `KtFile` can be garbage-collected, we do not need a `FileStructure`
  instance for it either.

^KT-65978 fixed
2024-03-11 23:07:04 +00:00
Dmitrii Gridin 8de680314e [SLC] reuse toLightClass for inner classes creation
This means:
* We will call `checkCanceled` under the hood.
* We will cache and reuse the result of conversion.

^KTIJ-28688
2024-03-11 21:42:39 +00:00
Dmitrii Gridin 2f2a17f570 [SLC] inject checkCanceled into declarations creation to improve responsiveness
^KTIJ-28688
2024-03-11 21:42:39 +00:00
Dmitrii Gridin 0ab105f265 [LC] KotlinAsJavaSupportBase: add checkCanceled
The jump from Kt into the Psi world is a good place to check
if we have been canceled

^KTIJ-28688
2024-03-11 21:42:39 +00:00
Vadim.Mishenev df1d44b15f KT-64051 [AA] Fix resolve of KDoc references to a typealias by full name 2024-03-11 21:38:09 +00:00
Nikita Bobko 9d566465e6 [test] Run checkers in metadata-like style to see what diagnostics metadata compilation omits
Review: https://jetbrains.team/p/kt/reviews/14807

Technically, *.ll.kt should have been covering that. But I see that
there slight differences
2024-03-11 18:07:52 +00:00
Alexander Udalov 2f056fe155 JVM: remove StubClassBuilder and its usage
After legacy light classes were removed, the only remaining usage was in
KotlinLightClassBuilderFactory where we ran JVM backend in the
LIGHT_CLASSES mode, and that was only used from diagnostic tests to
report JVM backend diagnostics.

We don't actually need to build stubs here, so we can just use ASM's
class writer, which means that StubClassBuilder and all its dependencies
can be removed.
2024-03-11 18:03:49 +00:00
Mikhail Glukhikh 633e96b966 K1/K2: add test for Future.get case 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 266669272d Rename/move/mark the test for KT-65184 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 98e4c64360 K1/K2: add more tests around intellij.vcs.git example 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh c966533d73 K2: reproduce a problem from intellij.vcs.git 2024-03-11 13:38:05 +00:00
vladislav.grechko 8a6467e524 [FIR] Add tests for KT-65184 to confirm its proper work
#KT-65184 Fixed
2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 78b6432ced K2: don't make T = Type! substitutions for constructors, including SAM
Without this commit we get some ABI changes and it looks bad.

Related to KT-65596
2024-03-11 13:38:05 +00:00
Denis.Zharkov 81414d758d K2: repeat K1 representation for flexible type parameters
This commit changes the behavior of KT-59138 effectively declining it in 2.0.
However, we plan to implement KT-59138 behavior under a feature
flag in 2.0 (see KT-66447), and switch this feature on version 2.x.

Also, this commit implements the LC resolution about postponing
KT-57014 change. We don't have KT-57014 described behavior in 2.0 anymore.
However, we plan to implement a deprecation warning here, see KT-65578.

After this commit, 6 diagnostic tests become incorrectly broken:
- 5 tests from PurelyImplementedCollection group
- a test platformTypes/nullableTypeArgument.kt

This commit also breaks currently fixed-in-k2 KT-50134
(it is fixed again in the following commits),
as well as KT-58933 (it will remain not fixed till we enable KT-59138
behavior again).

#KT-65596 In Progress
#KT-57014 In Progress
#KT-58933 Submitted
2024-03-11 13:38:05 +00:00
Mikhail Glukhikh db173b8ac5 K1/K2: add test for Comparator.comparing situation from intellij 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 993509c057 K1/K2: add test for streams situation from intellij 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 6e1b6427ab K1/K2: add a test confirming current behavior of KT-57014 case 2024-03-11 13:38:05 +00:00
Roman Golyshev b765cf3f99 KT-66411 [AA] Add fake source kind for single expression block around array assignments
A wrapper block was introduced as a part of fixing KT-59748, but was
assigned a real source, which had `getOrBuildFir` confused because
of the incorrectly built `KtToFirMapping`

It is relevant for:
- `if`, `when` expressions with an assignment as a single expression
- Kotlin code fragments,
when the assignment is being analysed as a single expression
in the fragment

^KT-66411 Fixed
2024-03-10 15:35:47 +00:00
Roman Golyshev ec06654a73 KT-66411 [AA] Add test for the getOrBuildFir on array assignment expression as a single when/if branch expression 2024-03-10 15:35:47 +00:00
Roman Golyshev 83a80a45a9 KT-66411 [AA] Add more tests for resolving compound set operators 2024-03-10 15:35:47 +00:00