Commit Graph

825 Commits

Author SHA1 Message Date
Denis.Zharkov 3e2f8b834c K2: Replicate K1 enhancement behavior for warning-mode top-level types
^KT-56657 Fixed
^KT-57307 Related
2023-03-17 08:52:31 +00:00
Denis.Zharkov 644391a8e0 K2: Fix Java enhancement when jsr305.jar is not in classpath
In that case, when loading Java, we just remember the name of `@Nonnull`
argument (javax.annotation.meta.When), and then use it during enhancement

^KT-56656 Fixed
2023-03-16 14:43:05 +00:00
Mikhail Glukhikh 58959951d3 K2: fix CCE during bound conversion for Java raw Kotlin-based type
#KT-56630 Fixed
2023-03-15 13:40:49 +00:00
Kirill Rakhman 9f33c64715 [FIR] Remove duplicate FirCallableSymbol.isStatic extension 2023-03-13 08:48:39 +00:00
Marco Pennekamp 1c46d37663 [AA] KT-56617 Build FirClassSymbols for Java classes lazily
- Some completion performance tests (e.g. IntelliJ: "empty place typing
  with library cache") spent a considerable amount of time in
  `KtFirSymbolProviderByJavaPsi.getNamedClassSymbol`.
- This commit introduces `KtFirPsiJavaClassSymbol`, which implements
  many `KtNamedClassOrObjectSymbol` properties with the `PsiClass`
  instead of the FIR class. The `FirClassSymbol` is built only when
  necessary. This improves performance when no "slow" properties need to
  be computed for the symbol.

^KT-56617 fixed
2023-03-09 18:35:56 +00:00
Marco Pennekamp 9cc6809ec6 [FIR] Fix JavaClass.modality for annotation classes and enums
- `JavaClass.modality` should return the correct modality instead of
  requiring the caller to handle annotation classes and enums.
2023-03-09 18:35:56 +00:00
Kirill Rakhman f946ddeb40 [FIR] Implement checks for contract not allowed
^KT-55423 Fixed
2023-03-09 08:32:02 +00:00
Ivan Kochurkin d829f8b684 [FIR] Drop using of JavaSymbolProvider and OptionalAnnotationClassesProvider in FirCommonSessionFactory
Drop using of all Java stuff inside FirCommonSessionFactory

^KT-56063
2023-03-03 20:58:24 +00:00
Kirill Rakhman 9268fd0e87 [FIR] Call enum entries in deserialized annotations as property access
KT-56177
2023-02-28 10:19:15 +00:00
Dmitriy Novozhilov f836d16dc6 [FIR] Don't generate synthetic declarations from java records from binary dependencies
^KT-56548 Fixed
2023-02-28 09:17:40 +00:00
Dmitriy Novozhilov 244dbb37cf [FIR] Properly set isOperator flag for java functions
^KT-56875 Fixed
2023-02-28 09:17:40 +00:00
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