Commit Graph

764 Commits

Author SHA1 Message Date
Denis.Zharkov b4b443034f K2: Fix false-positive OVERLOAD_RESOLUTION_AMBIGUITY
It's been introduced in the previous commit
("K2: Simplify handling mixed smartcast vs. original candidates")

Because previously, it was assumed wrongly that each next level of
ConeCallConflictResolver filter out the candidates that are 100% less
applicable/specific, but the main one (ConeOverloadConflictResolver)
either leaves the single candidate or the whole same set, thus at
FilteringOutOriginalInPresenceOfSmartCastConeCallConflictResolver
we've got 4 candidates only two of which we might filter out.
2023-02-15 08:13:57 +00:00
Denis.Zharkov 1e1d122dd3 K2: Simplify ConeConflictResolver hierarchy
Remove AbstractConeCallConflictResolver super class where it's actually
unnecessary
2023-02-15 08:13:56 +00:00
Denis.Zharkov b6b132a9a3 K2: Avoid false-positive overload resolution ambiguity with smart casts
The idea is that when we have successful candidates both from smart cast
and original type, we should discriminate in the favor of former ones.

While this problem (see kt55722.kt) existed before this branch is merged,
initially it was recognized on FP Ultimate when we stopped assuming
captured types from the same projections as equal (see kt55722Initial.kt).

^KT-55722 Fixed
^KT-55024 Fixed
^KT-56283 Related
^KT-56310 Related
2023-02-15 08:13:54 +00:00
Denis.Zharkov 427b221eaf K2: Get rid of redundant parameter of ConeCallConflictResolver methods
discriminateGenerics was only set to false in recursive calls of
ConeOverloadConflictResolver
2023-02-14 07:14:10 +00:00
Kirill Rakhman 314784f435 [FIR] Introduce FirDeclarationStatus.hasStableParameterNames
This flag is true by default but is set to false for

- Java methods and constructors
- interface delegation methods that delegate to Java

The NAMED_ARGUMENTS_NOT_ALLOWED logic is mostly refactored to use the
new flag though some custom logic remains for determining the correct
message and to work around a corner case with fake overrides.

The flag is (de)serialized from/to metadata. For backward compatibility
with K1, delegated methods to Java types are deserialized as stable.

^KT-40480 Fixed
2023-02-13 12:09:39 +00:00
Kirill Rakhman 152e63b198 [FIR] Remove redundant setting of DeclarationStatus properties 2023-02-13 12:09:39 +00:00
Dmitriy Novozhilov ea73cde5fb [Lombok] Make visibility of fields of @Value classes private by default (K2)
^KT-51092 Fixed
2023-02-10 12:30:13 +00:00
Dmitriy Novozhilov ff4c5c1d03 [FIR] Pass symbol of containing class to FirStatusTransformerExtension instead of fir node 2023-02-10 12:30:13 +00:00
Kirill Rakhman 22fd7921fe [FIR] Introduce MetadataBasedAnnotationDeserializer for compiling common
^KT-56361 Fixed
2023-02-08 13:32:33 +00:00
Ivan Kochurkin a9bac2f18b Add PackageAndMetadataPartProvider interface
Use it for parameter in MetadataSymbolProvider
2023-02-07 14:16:29 +00:00
Dmitriy Novozhilov 125b773205 [FIR] Introduce utility for creating ConeClassLikeLookupTagImpl from ClassId
`classId.toLookupTag()` looks much cleaner than `ConeClassLikeLookupTagImpl(classId)`
2023-02-02 08:24:48 +00:00
Dmitriy Novozhilov d856ae1f35 [FIR] Move common members in symbols up in the hierarchy 2023-01-31 07:53:11 +00:00
Artem Vasilev ccc3f52acf [FIR] Rename FirSyntheticPropertiesStorage, extract property creation 2023-01-30 20:05:51 +00:00
Artem Vasilev 075a80613b [FIR] Introduce cache for not-yet-enhanced synthetic properties
The original synthetic properties from Java were not cached anywhere and
created anew for every session. However, the enhanced properties are
(along with their originals) saved inside the session's cache, causing
inconsistency with newly created symbols via referential equality.
2023-01-30 20:05:50 +00:00
Mikhail Glukhikh 938e1d5ce8 K2: copy explicit receiver to dispatch receiver for static member accesses
Related to KT-55116
2023-01-26 15:27:57 +00:00
Kirill Rakhman f6c189be7b FIR: Handle visibility of public setter of protected synthetic property like in K1
K1 allows writing access to a public setter of a protected synthetic
property only if the call is inside a subclass. K2 previously allowed
that unconditionally. This changes brings the behavior in line with K1.

^KT-56050 Fixed
2023-01-26 11:33:30 +00:00
Ivan Kochurkin e22359cc10 [FIR] Add MetadataSymbolProvider
Extract common code from K1 to MetadataUtil
2023-01-24 15:27:12 +00:00
Denis.Zharkov 9c988fd8d8 K2: Introduce FirCachingCompositeSymbolProvider
The main idea is pre-computing the sets of names that might be
met there, that helps to decrease the sizes of the backing maps
(by avoiding irrelevant keys)

Totally, this branch with previous commits speeds up MT Full Kotlin
approximately on 3 seconds (~5%)
2023-01-19 10:57:43 +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 8bd3c9d019 [FIR] Don't transform nested classes during class update because of @JvmRecord annotation
^KT-55703 Fixed
2023-01-17 14:51:28 +00:00
Dmitrii Gridin 485fad1951 [FIR] FirJavaClass: make annotations and deprecationsProvider lazily enhanced
^KT-55387
2023-01-17 12:45:53 +00:00
Nikolay Lunyak f671a8c8a7 [FIR] Rename FirAnnotation.coneClassLikeType to unexpanded
The same reason
2023-01-17 06:26:36 +00:00
Nikolay Lunyak 0c86294ca4 [FIR] Rename FirAnnotation.classId to unexpandedClassId
This makes the eye catch each such thing in the source.
OptIn isn't that catchy, plus it may be declared
for the whole file, so noticing may be harder
2023-01-17 06:26:36 +00:00
Mikhail Glukhikh cbedbda527 Enhance API/messages around BinaryVersion / JvmMetadataVersion 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 52ab565cc6 Move LANGUAGE_TO_METADATA_VERSION to compiler:frontend.common.jvm 2023-01-16 18:14:52 +01:00
Mikhail Glukhikh f20e5daa92 K2: fix property VS field resolve in anonymous class case
Related to KT-55017, KT-50082
2023-01-13 13:49:20 +00:00
Dmitriy Novozhilov 42db0b14f0 [FIR] Move all type construction utilities into one file 2023-01-12 17:45:40 +00:00
Mikhail Glukhikh 7904f23660 FE: add & fix test with intersection property shadowed by base field 2023-01-09 21:37:22 +00:00
Mikhail Glukhikh 59bafedd8a K2 resolve: prefer derived class property to base class field
#KT-50082 Fixed
2023-01-09 21:37:21 +00:00
Ilya Kirillov ae68f08856 [FIR] make FirJavaClass.superTypes to be lazily enhanced
This should solve the problem with deadlocks/performance in the K2 IDE

This is a temporary solution until the ^KT-55387 is properly fixed

^KT-55387
^KT-54890
2023-01-06 18:55:43 +00:00
Mikhail Glukhikh 0d50f71fb8 K2: expand type aliases in annotation position #KT-55615 Fixed 2023-01-04 10:06:39 +00:00
Mikhail Glukhikh f33f87e3d4 K2: drop unused qualifier in FirJavaTypeRef 2022-12-20 11:04:27 +00:00
Mikhail Glukhikh 582b640bec K2: use MutableOrEmptyList for annotations storage in FIR elements 2022-12-20 11:04:25 +00:00
Ilya Kirillov 68a17242b3 [FIR] fix NPE on missing java annotations qualifier
^KTIJ-23075 fixed
2022-12-14 09:58:07 +00:00
Dmitriy Novozhilov d898e256ca [FIR] Don't update explicit delegated constructor calls of classes with @JvmRecord
^KT-54573 Fixed
2022-12-09 12:02:08 +00:00
Egor Kulikov dbfe33c00d [FIR] Make default values for value parameters lazy in RawFirBuilder
Sixth step for ^KT-52615

Merge-request: KT-MR-7926
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2022-12-08 13:32:37 +00:00
Yan Zhulanow c8e9cfde0b [FE] Read Java static field initializer lazily (KTIJ-23043) 2022-12-08 10:46:43 +00:00
Egor Kulikov fb2485f83c [FIR] Make constructor delegate lazy in RawFirBuilder
Fifth step for ^KT-52615

Merge-request: KT-MR-7860
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2022-12-02 03:12:51 +00:00
Yan Zhulanow fe69b21aed [FE] Fix 'containingClassForStaticMemberAttr' for fake overrides (KTIJ-22808) 2022-11-30 04:12:26 +00:00
Dmitrii Gridin 3bc9299b3b [FIR] SignatureEnhancement: drop redundant 'resolvePhase' for type parameter
^KT-54826
2022-11-24 18:32:45 +00:00
Dmitrii Gridin ec613e57ef [FIR] add Enhancement wrapping for type parameters
^KT-55095 Fixed
2022-11-24 18:32:43 +00:00
Ivan Kochurkin 8883de3f00 [FIR] Don't resolve Enum.declaringClass and Enum.getDeclaringClass
^KT-53946 Fixed
2022-11-23 18:29:29 +00:00
Ilya Kirillov 7781ad67d4 [FIR] introduce FirValueParameter.containingFunctionSymbol
^KT-55034 fixed
2022-11-22 18:25:30 +01:00
Artem Vasilev 02484baf07 [FIR] Set Java constructor source to Java class's when it's implicit
When there are no declared constructors in Java class, make
javaConstructor's source element point to the class declaration,
making it possible to navigate from constructor's invocation there.

^KTIJ-22360 Fixed
2022-11-17 13:18:30 +00:00
Dmitrii Gridin 86422d0944 [FIR] FirReceiverParameter: rename type to typeRef
^KT-54417
2022-11-17 09:50:17 +00:00
Dmitrii Gridin 22cfea5058 [FIR] introduce KtFakeSourceElementKind.ReceiverFromType
^KT-54417
2022-11-17 09:50:13 +00:00
Dmitrii Gridin be7d282974 [FIR] introduce FirReceiverParameter
^KT-54417
2022-11-17 09:50:09 +00:00
Ilya Kirillov 8dab560d6e [LL FIR] fix status resolution of static enum members
Before, BODY_RESOLVE phase were used for them but status may be unresolved.
This caused CCE on accessing resolved status for such static enum members.

Now, those declarations are created with the status of owning enum as the status is taken from that class.
2022-11-16 19:44:18 +00:00
Ilya Chernikov 8f18ab19f7 FIR: use serialization extension protocol correctly
otherwise the deserialization breaks on KLibs
2022-11-12 14:34:08 +01:00