Commit Graph

5608 Commits

Author SHA1 Message Date
Svyatoslav Kuzmich 54a45c49f8 [Wasm] Add Wasm platform and K1 FE infrastructure 2023-02-24 01:05:23 +01:00
Vladimir Dolzhenko 3e99807436 Add ability to provide specific AbsentDescriptorHandler
#EA-457188

Merge-request: KT-MR-8900
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-02-22 12:44:46 +00:00
Yahor Berdnikau 0cad069522 [Build] Pin api and language level to 1.8 in Kotlin compiler modules used by KGP
This is required to be able to compile KGP and it's dependencies which
set LV to 1.4 when repo will use LV 1.9. This caused by the change how
enums are compiled (KT-48872).
2023-02-18 13:26:54 +00:00
Dmitriy Novozhilov bdf8e6f3a5 [FIR] Extend capacity of ArrayMapImpl until it fits required size
There are cases when we have some indices in TypeRegistry left from
  previous compilations, so registering new service may increase index
  not by one
So such situation is possible:
First compilation (jvm project): register 20 different jvm services in
  session + one from compiler plugin (with index 21)
Second compilation (common project): register only 10 common services in
  session + one from compiler plugin (with index 21)
*numbers are imaginary

And in this situation increasing `ArrayMapImpl.data` size only one time
  may not cover required index

^KT-56685 Fixed
2023-02-16 10:25:20 +00:00
Stanislav Erokhin 57eae167cc Restore FunctionClassKind for compatibility with Android IDEA plugin 2023-02-10 16:01:05 +00:00
Stanislav Erokhin bec9ad0f6b Minor. Rename FunctionClassDescriptor#functionKind -> functionTypeKind
This commit is needed for the following commit.
There we will restore the compatibility API with Android IDEA plugin
2023-02-10 16:01:04 +00:00
Dmitriy Novozhilov 0550f0d394 [Lombok] Make visibility of fields of @Value classes private by default (K1)
^KT-51092
2023-02-10 12:30:12 +00:00
Dmitriy Novozhilov a9248569a6 [FIR] Fix reporting of UNINITIALIZED_ENUM_ENTRY in init blocks
^KT-41126 Fixed
2023-02-10 12:30:12 +00:00
Vladimir Dolzhenko b04b3d389f Add ability for DeclarationDescriptor validation
Not fully initialized DeclarationDescriptor could leak to bindingTrace.
It is hard to detect the outcome of that kind of leakage due to
possibility to have not fully initialized instances if PCE happens in
the middle of publication and instance full initialization.

#KT-56364
#KT-56388
#KT-54085
#KT-55150
2023-02-07 17:40:42 +00:00
Ivan Kochurkin a9bac2f18b Add PackageAndMetadataPartProvider interface
Use it for parameter in MetadataSymbolProvider
2023-02-07 14:16:29 +00:00
Dmitrii Gridin 4dbce37c0f [SLC] implement DefaultAnnotationsProvider
^KT-56046
2023-02-03 19:48:48 +00:00
Denis.Zharkov 6d7096b5e9 IR: Fix StackOverflowError caused by using DNN type in lambda
^KT-54140 Fixed
2023-02-03 14:08:57 +00:00
Dmitriy Novozhilov 89c42e20c9 [FIR] Consistently use _function_ instead of _functional_ in names of classes and functions 2023-02-02 08:24:52 +00:00
Dmitriy Novozhilov d1b797ed97 [FIR] Generify resolution and inference of arguments of functional types 2023-02-02 08:24:50 +00:00
Dmitriy Novozhilov 67aa80562d [FE] Completely replace FunctionClassKind with FunctionalTypeKind
FunctionalTypeKind can be used in FE 1.0 too, so there is no need to
  keep both classes. Also, removal of FunctionClassKind simplifies work
  with FunctionalTypeKind in common code, like Analysis Api
2023-02-02 08:24:50 +00:00
Dmitriy Novozhilov e0c8f2354a [FIR] Properly implement FirFunctionalTypeKindService
This implementation takes additional functional type kinds from compiler
  plugins into account
2023-02-02 08:24:49 +00:00
Nikita Bobko 44b1cf6c46 Add docs for different metadata versions and proto files
Review: https://jetbrains.team/p/kt/reviews/8401
In scope of KT-55082
2023-02-01 15:13:34 +01:00
Vsevolod Tolstopyatov 79f6d4b590 Address classloader leak in a recently-introduced ClassValueCache
Root cause:
Cached in ClassValue values are prohibited to reference any java.lang.Class or ClassValue instances as they are considered as strong roots that prevent Class and ClassValue garbage collection,
creating effectively unloadable cycle.
This problem is also known as JDK-8136353.

Actions taken:
* Extract anonymous ClassValue instance into a separate static class that does not capture anything implicitly
* Wrap cached values in ClassValue into SoftReference to avoid unloadable cycles

^KT-56093 Fixed
2023-01-31 16:22:03 +01:00
Vladimir Dolzhenko edf9c3a2f5 Add more diagnostic info
Resolver could be GCed if there is no any valid hard reference to it.
Some impl of PackageFragmentProvider (like DelegatingPackageFragmentProvider)
keep hard ref to resolver.
For the sake of investigation it is worth to know what kind of PFP is there.

#EA-725255

Merge-request: KT-MR-8581
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-01-31 09:09:28 +00:00
Dmitriy Novozhilov a83caec94f [FE 1.0] Implement deprecation PRIVATE_CLASS_MEMBER_FROM_INLINE_WARNING warning
^KT-55179
^KT-56171 Fixed
2023-01-31 07:53:11 +00:00
Alexander Udalov 25c600c556 Fix incorrect check for major version in core:metadata
It affected the changed test in the following way: "strict metadata
version semantics" is a flag which is written to the .kotlin_module file
between the version and the protobuf data, see `ModuleMapping:73`. But
flags are written only for Kotlin 1.4+, i.e. if `isKotlin1Dot4OrLater`
returns true. So in the test, the flag was not written, thus we did not
detect that the module actually has incompatible metadata, and thus
incorrectly did not report an error.

It also has an effect that version requirements for nested classes will
now be written correctly to protobuf with metadata version 2.0+.
2023-01-30 09:30:00 +00:00
Dmitriy Novozhilov 66544a4e00 Switch kotlin version to 1.9
with appropriate fixes in testdata, tests and other
places.
2023-01-30 09:29:55 +00:00
Nikolay Lunyak e2403c801f [FIR] KT-55747: Report error for operator fun mod
^KT-55747 Fixed

Merge-request: KT-MR-8522
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-01-30 08:48:33 +00:00
Alexander Udalov 99b38ccb74 Reflection: fix exceptions on concurrent access to some properties
Using `ReflectionProperties.lazy` is incorrect because it allows several
threads to observe different resulting values if they're computing it
simultaneously (unlike `lazy(PUBLICATION)`, which always returns the
value that "won the race").

In the case of property delegates, for example, if we're invoking
`isAccessible = true` and then `getDelegate()` concurrently, it might
happen that when some thread invokes `getDelegate()`, it gets the
underlying Field object which was written by another thread and which
has not yet been made accessible, leading to
IllegalPropertyDelegateAccessException.

 #KT-27585 Fixed
2023-01-27 20:23:23 +00:00
Ivan Kylchik 13cad2a820 Don't save constant value for non-resolved array expression in K1
#KT-55912 Fixed
2023-01-27 09:56:35 +00:00
Ivan Kochurkin e22359cc10 [FIR] Add MetadataSymbolProvider
Extract common code from K1 to MetadataUtil
2023-01-24 15:27:12 +00:00
Ivan Kochurkin 3f68694b0f Move MetadataPartProvider to deserialization.common
To make it possible to use it in FIR compiler
2023-01-24 15:27:11 +00:00
Alexander Udalov c58314fddf Reflection: improve and optimize kotlinFunction/kotlinProperty
- Make the implementations very similar, to fix KT-54833 where the
  companion object case was forgotten for kotlinProperty.
- Optimize both functions to look up the function/property by name
  first, to cover the most probable case when the JVM name of a
  declaration is equal to its Kotlin name. This fixes KT-55937.

 #KT-54833 Fixed
 #KT-55937 Fixed
2023-01-23 20:43:00 +01:00
Alexander Udalov aa7b4cfbe6 Do not eagerly compute deserialized typealias constructors
Otherwise, when adding a typealias to core/builtins, it leads to an
exception "JvmBuiltins instance has not been initialized properly". It
happens because we start computing typealias constructors even before
the compiler has been initialized properly.

Basically we're creating the container, and as a part of it, we're
computing default imports, and for that we need to get all top-level
classifiers from scopes imported by default, which includes typealiases.
Eager call to `getTypeAliasConstructors` here results in computing
constructors of the class descriptor on the RHS of the type alias, which
is not possible if that class is built-in, since the container has not
yet been created and thus `JvmBuiltIns` has not been initialized yet.

No tests added, and no issue is affected because, as mentioned above,
the problem is only reproducible if we add something to core/builtins.
2023-01-23 20:35:11 +01:00
Roman Efremov 878608b7b2 Don't add Enum.entries to scope if it can't be called
^KT-53929 Fixed
2023-01-23 12:53:06 +01:00
Roman Efremov 2dc3871954 Add "hasEnumEntries" class flag to kotlinx-metadata
^KT-53929 Fixed
2023-01-23 12:53:06 +01:00
Roman Efremov 14b4cdc7c4 Write "hasEnumEntries" flag into metadata when feature enabled
^KT-53929 Fixed
2023-01-23 12:53:04 +01:00
Roman Efremov 3c5e556ba6 Add "hasEnumEntries" flag to class metadata
With this flag we can distinguish enum classes that have `entries`
property in the compiled bytecode (see `LanguageFeature.EnumEntries`).
This is needed to be able to understand in the frontend whether
`entries` can be called for that class. For Native and JS, this is
currently not possible even if the feature is enabled, but the class
was compiled with disabled feature.

^KT-53929 Fixed
2023-01-23 12:50:14 +01:00
Denis.Zharkov dab50daf56 K2: Add ability identify DI components by string key instead of KClass
It allows having several the same typed-component in the container
2023-01-19 10:57:42 +00:00
Denis.Zharkov 58c1b5dd1f K2: Optimize AbstractFirDeserializedSymbolProvider
Avoid filling caches with keys that are definitely empty
(if it's cheap to compute that), to decrease the size of backing maps.

The strategy is pre-computing the sets of names that might be met.
NB: the size of the sets is way fewer than a size of all queried names.
2023-01-19 10:57:42 +00:00
Dmitriy Novozhilov 259303ca50 [FIR] Fix loading of classId for nested enums in java annotation arguments
^KT-55887 Fixed
^KT-55976
2023-01-17 14:51:29 +00:00
Jinseong Jeon b088e742ae Introduce a util to copy TypeMappingMode for UAST 2023-01-17 13:56:42 +01:00
Nicklas Ansman Giertz 115bc6ac89 KAPT: Fix an ISE when processing unresolved generic types
Error types that are generic could sometimes throw an ISE when
generating the stub.

This fixes KT-43786
2023-01-17 11:40:13 +01:00
Mikhail Glukhikh cbedbda527 Enhance API/messages around BinaryVersion / JvmMetadataVersion 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 13502abab9 Fix FIR bootstrap in version 2.0 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh bbeae23b04 Allow to read metadata 2.0 from version 1.8 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 89dd28226b BinaryVersion: introduce isCompatibleWithCurrentCompilerVersion 2023-01-16 18:12:55 +01:00
Mikhail Glukhikh 3dc05f4ec5 Introduce language version 2.0 and associate K2 compiler with it 2023-01-16 18:12:55 +01:00
Dmitriy Novozhilov d5a76a1b3b [AA LC] Keep original qualifier while translating error cone types to Psi types 2023-01-12 17:45:08 +00:00
Dmitriy Novozhilov bd26c29229 [FIR] Resolve arguments of error types during type resolution 2023-01-12 17:45:06 +00:00
Denis.Zharkov b009ee3744 Add @SinceKotlin and KDoc for ContextFunctionTypeParams
Initially, it was added accidentally as part of e3f987459c
and missed all out processes.

Adding @SinceKotlin("1.7") after the annotation has already been
published before is not really a problem, because it only may be used
with an experimental `-Xcontext-receivers` flag, thus it doesn't have
to be a part of our regular backward compatibility routine.

^KT-55226 Fixed
2023-01-12 16:53:48 +00:00
Mikhail Glukhikh 7904f23660 FE: add & fix test with intersection property shadowed by base field 2023-01-09 21:37:22 +00:00
Nikolay Lunyak e6efde76dc [FIR JS] Reuse declarations from JsStandardClassIds in both frontends 2023-01-09 08:57:13 +00:00
Nikolay Lunyak 5817155616 [FIR JS] Implement FirJsNameChecker 2023-01-09 08:57:12 +00:00