Commit Graph

110118 Commits

Author SHA1 Message Date
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
Kirill Rakhman 72235b8527 [FIR] Report INNER_CLASS_CONSTRUCTOR_NO_RECEIVER on delegated constructor calls
#KT-59677 Fixed
2024-03-19 12:51:06 +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
Vyacheslav Gerasimov 069c920a5c Build: Use jdk-release compiler option to build kotlin-stdlib
Use JDK11 with `-Xjdk-release=6` for kotlin-stdlib.
Use JDK11 with `-Xjdk-release=7` for kotlin-stdlib-jdk7.
This allows dropping JDK6 and JDK7 from our build completely and remove
`kotlin.build.isObsoleteJdkOverrideEnabled` #KTI-1220.

 #KT-57808
2024-03-19 12:32:39 +00:00
Stanislav Ruban e9d5396fa9 [FIR][checkers] Handle ConeHiddenCandidateError in FirDestructuringDeclarationChecker properly
#KT-66595 Fixed
2024-03-19 12:32:17 +00:00
Stanislav Ruban 89a0cde514 [tests][FIR][checkers] Add test data for KT-66595 2024-03-19 12:32:17 +00:00
Alexander Udalov 8ad38db2ad JVM IR: do not use JvmMethodParameterKind 2024-03-19 11:12:31 +00:00
Alexander Udalov d9bc714992 JVM IR: remove usages of JvmMethodParameterKind.RECEIVER/CONTEXT_RECEIVER
Also slightly refactor ExpressionCodegen.visitCall.
2024-03-19 11:12:31 +00:00
Leonid Startsev dbb7ab1760 Add @Deprecated annotation to a synthetic $serializer class
in K2 so it matches K1 behavior.

Deprecation is required, so the declaration will not be visible to user in completion in the IDE.

#KT-65757 Fixed
2024-03-19 10:57:27 +00:00
Ilya Chernikov 0df3a37303 K2 Scripting, Fir2Ir: allow out of order supertypes declaration
fix script declarations registration logic in Fir2Ir to allow
supertypes of a class to be defined later than the class itself.

#KT-64534 fixed
2024-03-19 08:24: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 53f2dfec41 [Kapt4] Update Kapt4 test data after AA Standalone fix for sealed inheritors
- The Standalone Analysis API now correctly calculates sealed inheritors
  in source modules. This causes Kapt4 to pick up on sealed subclasses
  in the `modifiers` test. The change is in line with the non-FIR test
  results in `modifiers.txt`.

^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 3fbb7bc920 K2: report MISSING_DEPENDENCY_CLASS in case of error type of expression
This commit is intended to get a more clear diagnostic in case when
the type checker creates an inconsistent error type due to some
classifier inaccessibility. Before this commit, we reported simply
ARGUMENT_TYPE_MISMATCH (see test). Now we report also
MISSING_DEPENDENCY_CLASS by analyzing an error type of a qualified
expression.

#KT-66356 Fixed
2024-03-18 18:11:14 +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
Leonid Startsev 7c8c65d291 Call a specified function in intrinsic if polymorphic serializer is provided for interface.
This prioritizes module contents over default polymorphic serializer.

See https://github.com/Kotlin/kotlinx.serialization/issues/2060 and https://github.com/Kotlin/kotlinx.serialization/pull/2565
2024-03-18 17:21:16 +00:00
Igor Yakovlev c8f84a74b9 [Wasm] Fix invalid value passing through externalized FrameworkAdapter
Fixed #KT-66440
2024-03-18 17:12:04 +00:00
Stanislav Ruban 29efe8645c [FIR][checkers][JS] Expand type aliases to supertypes in FirJsInheritanceClassChecker
#KT-66673 Fixed
2024-03-18 15:57:59 +00:00
Stanislav Ruban 1f3d318cae [tests][FIR][checkers][JS] Add test data for KT-66673 2024-03-18 15:57:59 +00:00
Kirill Rakhman 672512d19d [FE] Skip CST computation if list of types has exactly one entry
Otherwise, we can get in a situation where the single item is flexible,
and we replace its attributes with the attribute of the lower bound,
which messes up `EnhancedTypeForWarningAttribute`.

#KT-65193 Fixed
2024-03-18 15:52:50 +00:00
Kirill Rakhman 19cc739118 [Tests] Reproduce #KT-65193 2024-03-18 15:52:50 +00:00
Dmitrii Krasnov ffef1630dd [Gradle] Added provisioned.ok after k/n bundle installation
Added provisioned.ok file to ensure
that Kotlin Native bundle has been successfully installed.

^KT-66309 Fixed
2024-03-18 13:35:41 +00:00
Bogdan Mukvich e72bac333f Update SPDX gradle plugin
* contains local license cache
* add more info to license parsing exception
https://github.com/Badya/spdx-gradle-plugin/commit/9802dbe05f9462c9e24f5a62af4678754d367648

KTI-1630
2024-03-18 12:56:50 +00:00
Wojciech Litewka 6af930fc0e Partially revert "[IR] Hide constructors of implementation classes behind factory functions"
To restore binary compatibility with a compiler plugin used in
one of user projects.

#KT-66636 Fixed
2024-03-18 12:17:52 +00:00
Alexander Udalov e007153ae6 Parcelize: remove testData for old JVM backend
Old JVM backend implementation was removed in 163a052f98 along with
tests, but .asm.txt files were not removed.
2024-03-18 12:06:36 +00:00
Sebastian Sellmair 426d71b088 [aa-klib-reader] Only resolve symbols from the associated library/sourceFile
Previously the addresses were resolved by only respecting
CallableId or ClassId. This however, could lead to
resolving symbols that were not defined in the klib which
initially provided the declaration address.

E.g. this commit adds a test in `GetSymbolsTest`, where
```
// A.kt
private fun foo() = 42

// B.kt
private fun foo() = 42
```

In this case the two source files (A.kt and B.kt) defined
two distinct addresses for `foo`. However: Resolving
any of those two addresses would resolve both functions (A&B), which
is not expected.

^KT-66271 Fixed
2024-03-18 10:13:57 +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
Sebastian Sellmair 6d8a4a28af [FIR] Deserialize Klib KlibMetadataProtoBuf. classFile, functionFile & propertyFile
klibs provide information about the container source file
in the KlibMetadataProtoBuf extensions for functions,
properties and classes.

This information is deserialized and attached to the
`klibSourceFile` extension (stored in FirDeclarationDataRegistry)

^KT-66271 Fixed
2024-03-18 10:13:57 +00:00
Kirill Rakhman 85a1d67d19 [FIR] Fix giant type produced by CST
#KT-65704 Fixed
2024-03-18 08:41:26 +00:00
Kirill Rakhman 81c0ee471f [Tests] Reproduce #KT-65704 2024-03-18 08:41:26 +00:00
Ilya Goncharov 8b258426ee [Wasm]Log webpack result only in there was infrastructure logging before 2024-03-16 09:44:51 +00:00