Commit Graph

2650 Commits

Author SHA1 Message Date
Dmitriy Novozhilov f18aa5e70f [Test] Add regression test for KT-66638 2024-03-19 07:40:09 +00:00
Marco Pennekamp 1374bc8e2d [LL] Implement a common LLSealedInheritorsProvider
- The new `LLSealedInheritorsProvider` is based on the previous
  sealed inheritors provider implementation in the IDE. It uses the
  new direct inheritors provider and the module dependents provider to
  implement the same functionality that was previously confined to the
  IDE. With this design we avoid duplication of complex logic such as
  the KMP handling in `searchInheritors`.
- The implementation is designed to work in the production Standalone
  mode and the aforementioned services have already been implemented for
  Standalone in prior commits. Now we can get rid of the problematic
  `SealedClassInheritorsProviderForTests` and tests should more closely
  match production behavior.
- In IDE mode tests, `LLSealedInheritorsProvider` is used with
  Standalone Analysis API provider implementations. This is in line with
  the rest of the test infrastructure, where Standalone AA providers are
  generally used, as IDE providers aren't available.
- `KotlinSealedInheritorsProvider` is made obsolete by the common sealed
  inheritors provider.

^KT-66013 fixed
^KT-64505 fixed
2024-03-18 21:14:36 +00:00
Mikhail Glukhikh 2d755aabe7 K1/K2: add test data for KT-66356 2024-03-18 18:11:14 +00:00
Kirill Rakhman 81c0ee471f [Tests] Reproduce #KT-65704 2024-03-18 08:41:26 +00:00
Kirill Rakhman 2095f90e69 [FIR] Fix exception in Java scope caused by inherited member with implicit return type
It's caused by checking the return type of an inherited property.
toConeKotlinTypeProbablyFlexible() returns an error type when the
type ref is unresolved instead of throwing.
This "breaks" some override checks and in the added test, it leads
to an additional candidate being created for a synthetic property.
However, the candidate has applicability K2_SYNTHETIC_RESOLVED
and gets filtered out because the real property has a higher
applicability.

#KT-66392 Fixed
2024-03-15 12:01:55 +00:00
Stanislav Ruban bf77cc3d0c [tests][FIR][checkers][JS] Add test data for KT-66474 2024-03-15 11:40:55 +00:00
Mikhail Glukhikh cd20f31810 K2: introduce JavaTypeParameterDefaultRepresentationWithDNN exp. feature
#KT-66447 Fixed
2024-03-14 22:39:03 +00:00
Alevtina.Gamzikova 7d06b34bfa [Test] KT-64350 Add testcases 2024-03-14 20:41:53 +00:00
Jaebaek Seo 90ccdb79ed K2: Set special function kind to function param with receiver
`StubBasedFirTypeDeserializer` handles function parameter with a
receiver with a special exception, which sets it as
`ExtensionFunctionType`, but skips setting special function kinds for it
even when the function parameter type is a special function kind. This
drops `Composable` annotation from a lambda expression if the function
parameter taking the lambda expression as an argument has a receiver,
which causes a severe CodeGen error for Compose app on K2 Android
Studio.

^KT-66526 Fixed
2024-03-14 20:08:24 +00:00
Sergej Jaskiewicz 9851ff1905 [FIR] Reproduce KT-66277, KT-66279, KT-66512 and KT-66534 2024-03-14 18:34:30 +00:00
Artem Kobzar eb8054ac1e [K/Wasm] Fix object optimization false trigger on non-pure objects ^KT-66471 Fixed 2024-03-14 17:12:45 +00:00
Alexander Udalov 7d6cd8d126 Tests: remove diagnostic test with incorrect compiler behavior
In fact the latest compiler (neither K1 nor K2) does NOT report an error
here, see KT-66522. The error was there in the diagnostic test because
the test used custom code which invoked parts of the old JVM backend to
report signature clash errors.

The issue is rather minor and is present since 1.5, so to reduce
confusion, the test is deleted.

 #KT-66522
2024-03-14 12:38:48 +00:00
Alexander Udalov d986e0ee9c Tests: move more diagnostic tests to testsWithJvmBackend
In this commit, tests where backend diagnostics were reported correctly
are being moved.

FirScopeDumpHandler was added to FIR diagnostic tests with JVM backend
to support `SCOPE_DUMP` in `overridesBuiltinNoMagic.kt` and
`charAtAndOverload.kt`.
2024-03-14 12:38:48 +00:00
Alexander Udalov 56a1a3153b Tests: move inline class-related diagnostic tests
... with backend-reported diagnostics to testsWithJvmBackend.
2024-03-14 12:38:47 +00:00
Alexander Udalov d08c904b0c Tests: copy diagnostic test to codegen/box
This is basically a copy of the test
`diagnostics/tests/j+k/primitiveOverrides/triangleWithFlexibleTypeAndSubstitution4.kt`.
The diagnostic version of the test is not removed because it has
frontend-specific diagnostics `FIR_DUMP` and `SCOPE_DUMP`.

This test is copied to make it clear that it actually passes in K1, and
new errors in K2 here are technically a breaking change, see KT-66529.
The error CONFLICTING_INHERITED_JVM_DECLARATIONS was present there only
because diagnostic tests used parts of the old JVM backend to report JVM
backend diagnostics.

 #KT-66529
2024-03-14 12:38:47 +00:00
Alexander Udalov c997e9f142 Tests: move diagnostic test to testsWithJvmBackend
There's a difference in behavior of K1 and K2 here, see KT-66528.

 #KT-66528
2024-03-14 12:38:46 +00:00
Alexander Udalov 81a9f5654e Tests: remove diagnostic tests which are present elsewhere
- `typeParameterWithTwoBounds.kt` is already present in
  `diagnostics/testsWithJvmBackend/duplicateJvmSignature/erasure/`.
- `clashWithCompanionObjectField.kt` is already present in
  `codegen/box/fieldRename/jvmFieldNoClash1.kt`.
- `jvmFieldAndJavaGetter.kt` is already present in
  `codegen/box/jvmField/noClashWithInheritedJavaMethod.kt`.

In case of two latter tests on JvmField, there's (correctly) no error
reported in JVM IR, which is why those are box tests.
2024-03-14 12:38:44 +00:00
Dmitriy Novozhilov c62fe0d107 [Test] Add regression test for KT-66336 2024-03-14 12:23:36 +00:00
Kirill Rakhman 9f750d3036 [Tests] Reproduce current behavior of operator/infix resolution
#KT-66504
#KT-66453
#KT-58260
2024-03-14 11:32:38 +00:00
Nikita Bobko a8275c99a3 [FIR, IR] Check for strict subtypes during actualization
^KT-65775 Fixed
Review: https://jetbrains.team/p/kt/reviews/14906/timeline
2024-03-14 10:53:43 +00:00
Yan Zhulanow 1f39bc9a18 [Analysis API] Add tests for foreign values 2024-03-14 10:20:29 +00:00
Yan Zhulanow 2dd16e1179 [Analysis API] Fix 'getContainingDeclaration()' for foreign values
Foreign values (such as '_DebugLabel' properties contributed by the
debugger) don't have a parent (or a valid source element in general).

^KTIJ-27382 Fixed
2024-03-14 10:20:29 +00:00
Kirill Rakhman 786c37286c [FIR] Fix crash caused by cast of raw type to simple type
#KT-66552 Fixed
2024-03-14 08:42:20 +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
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
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
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