Commit Graph

5034 Commits

Author SHA1 Message Date
Ilya Chernikov d5ad41fa28 K2 Scripting: add failing test for #KT-64241 2024-03-19 15:38:35 +00:00
Kirill Rakhman 988edab7a0 [Tests] Add regression test for #KT-58575
#KT-58575 Fixed
2024-03-19 15:34:43 +00:00
Dmitrii Gridin a0120d28cc [FIR] FirResolvePhase: introduce isItAllowedToCallLazyResolveToTheSamePhase
To have explicitly declared contracts
2024-03-19 14:53:28 +00:00
Dmitrii Gridin d67dde8395 [LL FIR] LLFirTargetResolver: rename isJumpingPhase into requiresJumpingLock
to avoid conflicting terms with jumping phases from `FirResolvePhase` KDoc
2024-03-19 14:53:28 +00:00
Dmitrii Gridin c7765258d1 [FIR] FirResolvePhase: introduce isItAllowedToCallLazyResolveTo
To explicitly declare when it is possible to call lazy resolve
2024-03-19 14:53:28 +00:00
Dmitrii Gridin f036954ac0 [LL FIR] LLFirLockProvider: drop checkContractViolations hack
This check was required due to missed proper implementation for
jumping locks. Now it is safe to call `lazyResolveToPhase` under the
jumping lock – it won't lead to any deadlocks or stack overflows.
2024-03-19 14:53:28 +00:00
Dmitrii Gridin e1bf85f790 [Analysis API] KtPsiTypeProvider: drop asPsiTypeElement method
This was an implementation detail of SLC.
In the case, if we want to have proper parents for type annotations
in light classes, we have to properly implement `PsiTypeElement`
for required declarations.

^KT-66603
^KT-56870
2024-03-19 13:57:23 +00:00
Dmitrii Gridin 2fbde7a85c [Analysis API] reuse PsiClassRenderer for PsiType render
To align the format with light classes as now we are powered by them

^KT-66603
2024-03-19 13:57:23 +00:00
Dmitrii Gridin 54aee57fec [LC] preserve type annotations from wildcard bound
^KT-66603
2024-03-19 13:57:23 +00:00
Dmitrii Gridin 96575a0bdb [Analysis API FIR] preserve type annotations on asPsiType conversion
^KT-66603 Fixed
2024-03-19 13:57:23 +00:00
Dmitrii Gridin 3c8a95e623 [LC] render all type annotations in tests
^KT-66603
2024-03-19 13:57:23 +00:00
Dmitrii Gridin 66d1839d20 [LC] add tests on nested type annotations
^KT-66603
2024-03-19 13:57:23 +00:00
Dmitrii Gridin cd4f87a8f3 [Analysis API] add tests on KtType conversion with annotations
^KT-66603
2024-03-19 13:57:23 +00:00
Dmitrii Gridin 6ba69482af [Analysis API Fe10] generate ExpressionPsiTypeProviderTest
^KT-66603
2024-03-19 13:57:23 +00:00
Dmitrii Gridin fdc0a8ec07 [Analysis API] render PsiType in tests properly
It should contain fully qualified names and annotations

^KT-66603
2024-03-19 13:57:22 +00:00
Sebastian Sellmair a13756cfe9 [aa-klib-reader] Move aa-klib-reader to pkg 'o.j.k.native.analysis.api'
To clearly distinguish this modules API from the Analysis API

^KT-66695 Fixed
2024-03-19 12:35:52 +00:00
Stanislav Ruban 89a0cde514 [tests][FIR][checkers] Add test data for KT-66595 2024-03-19 12:32:17 +00:00
Dmitriy Novozhilov f18aa5e70f [Test] Add regression test for KT-66638 2024-03-19 07:40:09 +00:00
Marco Pennekamp 9d2298b326 [AA] Resolve isSubClassOf from the context of a use-site session again
`isSubClassOf` was changed in an earlier commit to use the session of
`subClass` instead, but that approach comes with multiple problems:

- We need to resolve classes from the use-site to take actualization of
  `expect` types into account.
- If `superClass` is a builtin and we resolve supertypes from
  `subClass`'s session, we may get multiple instances of symbols for the
  same builtin from different sessions (i.e. one from a stdlib session
  via the use-site session and another from the fallback builtins
  provider for binary libraries if `subClass` is from a binary library).

^KT-66013
2024-03-18 21:14:36 +00:00
Marco Pennekamp 32337c8255 [AA] Render types in sealed inheritors tests as fully expanded types
- This avoids discrepancies between Standalone and IDE mode for sealed
  inheritor tests with type aliases from libraries, because in
  Standalone mode, libraries are deserialized with fully expanded types,
  while in IDE mode, libraries are deserialized from stubs, where type
  aliases are currently not expanded.

^KT-66013
2024-03-18 21:14:36 +00:00
Marco Pennekamp 2e00879fe1 [AA] Add sealed inheritors tests for inheritors with the wrong package
- Inheriting from a sealed class in the wrong package is illegal, so a
  library test makes no sense here, as the test infrastructure wouldn't
  be able to compile the library.

^KT-66013
2024-03-18 21:14:36 +00:00
Marco Pennekamp ed62211e06 [AA] Add packages to sealed inheritors tests
^KT-66013
2024-03-18 21:14:36 +00:00
Marco Pennekamp 4fa0f1316d [AA Standalone] Refactoring: Rename testKtFiles to sourceKtFiles 2024-03-18 21:14:36 +00:00
Marco Pennekamp a9d7b0c595 [AA Standalone] Consider type aliases in direct inheritors search
A type alias may still be inherited from. For example:

```
sealed class MyClass

typealias T = MyClass

class Inheritor : T() // `Inheritor` is a direct inheritor of `MyClass`.
```

The index is a simplified version of the IDE's
`KotlinTypeAliasByExpansionShortNameIndex`, but it should be sufficient
for virtually all cases.

^KT-66013
2024-03-18 21:14:36 +00:00
Marco Pennekamp 54f2655b4d [AA] Add sealed inheritors tests for type aliased classes/interfaces
- The test data is partially incorrect, as type alias support needs to
  be added to `KotlinStandaloneDirectInheritorsProvider`.

^KT-66013
2024-03-18 21:14:36 +00:00
Marco Pennekamp 5c8c3020c6 [AA] Add tests for getSealedInheritors
- Previously, the sealed inheritors provider was only tested indirectly
  through diagnostics tests on `when` expressions.

^KT-66013
2024-03-18 21:14:36 +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
Marco Pennekamp 48229f7faa [AA Standalone] Implement getRefinementDependents
^KT-66013
2024-03-18 21:14:36 +00:00
Marco Pennekamp b2639a469b [AA Standalone] Implement KotlinDirectInheritorsProvider
- We are relying on static indexing to find candidates for sealed
  inheritors, hence the extension to the index.
- The direct usage of `KotlinStaticDeclarationProviderFactory` in
  `KotlinStandaloneDirectInheritorsProvider` is not pretty, but a proper
  design requires making the static index available as a service and
  moving "static" services to the Standalone API (from AA providers).

^KT-66013
2024-03-18 21:14:35 +00:00
Marco Pennekamp 9bed2e974b [AA] Add KotlinModuleDependentsProvider.getRefinementDependents
- When calculating sealed inheritors for expect classes, we need to
  expand the search scope to modules with a depends-on/refinement
  dependency on the module containing the expect class, as these modules
  may contain additional sealed inheritors. `getRefinementDependents`
  allows us to get these refinement dependents to build the proper
  search scope.

^KT-66013
2024-03-18 21:14:35 +00:00
Marco Pennekamp 31a65871f2 [AA] Add KotlinDirectInheritorsProvider
- Direct inheritors are needed to calculate sealed inheritors. The new
  `KotlinDirectInheritorsProvider` can be used to implement a common
  sealed inheritors provider in LL FIR.

^KT-66013
2024-03-18 21:14:35 +00:00
Mikhail Glukhikh 2d755aabe7 K1/K2: add test data for KT-66356 2024-03-18 18:11:14 +00:00
Egor Kulikov 36b89f5e84 [FIR] Fix resolve for java synthetic properties in KDoc
^KT-62880 fixed
2024-03-18 17:35:32 +00:00
Sebastian Sellmair 6b98602afc [Analysis Api] Expose klibSourceFile via KtKlibSourceFileProviderMixIn
This `klibSourceFile` information is deserialized from klibs
to retain the information of the original SourceFile location
of a declaration.

^KT-66271 Fixed
2024-03-18 10:13:57 +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 8ac576614f Revert "Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551)"
This reverts commit 893e5cac
2024-03-15 11:33:10 +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
Dmitrii Gridin b3827947d9 [Analysis API] Update KDoc for KtPsiTypeProvider#asKtType 2024-03-14 18:05:15 +00:00
Dmitrii Gridin 5689dedea0 [Analysis API FIR] KtFirPsiTypeProvider: drop redundant TODO
Regular type annotations work as expected

^KT-62351 Obsolete
2024-03-14 18:05:15 +00:00
Dmitrii Gridin ba421aa320 [Analysis API FIR] KtFirPsiTypeProvider: support type parameter position in asKtType
^KT-66530
2024-03-14 18:05:15 +00:00
Dmitrii Gridin 675bf36049 [FIR] JavaTypeParameterStack: allow nullable return from get
It is not always possible to have the correct mapping,
at least on the Analysis API side

^KT-66530 Fixed
2024-03-14 18:05:15 +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