Commit Graph

3142 Commits

Author SHA1 Message Date
Alexander Udalov 96ddd9bbf3 K2: report INLINE_CALL_CYCLE error in JVM backend
This fixes the following
FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated tests:

  testPropertyInlineCycle
  testInlineCycle
  testSuspendInlineCycle
  testIndirectInlineCycle

 #KT-59586
2023-07-29 01:14:29 +02:00
Ivan Kylchik d0da736b13 [FIR] Add the new test set to render diagnostics from IR const evaluator 2023-07-27 22:50:21 +00:00
Alexander Udalov c5f44486a9 Rename KaptAnonymousTypeTransformer and move to frontend.java
This is needed in order to run light analysis mode tests for JVM IR
backend. In the subsequent commit, this extension is added to light
analysis mode tests.

Kapt stub generation uses this extension to transform local types to
non-local:

    private val x = object {}

With this extension, x's type will be `Any`. Without it, it will be an
anonymous type. This anonymous type was not a problem for the old JVM
backend, but it's difficult to translate it in the IR infrastructure in
the light analysis mode where bodies are not resolved.

When kapt stub generation works with JVM IR enabled,
KaptAnonymousTypeTransformer ensured that backend would not crash and
stubs would contain something useful.

However, this is not happening in light analysis mode tests, which are
supposed to check how compiler behaves in the light analysis mode which
is used in kapt.
2023-06-22 17:10:50 +02:00
Mikhail Zarechenskiy 1df4893a43 Extract diagnostics about an unsupported case of inheritance from Java
^KT-59152
2023-06-19 15:21:32 +00:00
Ilya Kirillov c114cb67cb [Java resolution] make it possible to provide custom source element for JavaElement
This is needed to allow using PSI pointers in IDE in JavaElement.
`JavaElement`s are reused between read actions,
so underlying PSI elements might be invalidated when using hard PSI references

^KT-58194
2023-05-31 13:01:19 +00:00
Alexander Udalov 75197d1b86 JVM: remove diagnostics related to JVM target 1.6 2023-05-19 13:24:00 +00:00
Mikhail Glukhikh 41e551e321 K1: add deprecation warning for property/field pair with different types
#KT-57905 Fixed
2023-04-26 11:47:16 +00:00
Alexander Udalov e0b5ae7781 JvmDefault: remove diagnostics related to @JvmDefault
#KT-54746
2023-04-25 14:33:00 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Nikita Bobko 5a96754aec Shift ReferencesToSyntheticJavaProperties feature release from 1.9 to 2.1
Other related tests:
- testGenericJavaProperty
- testFunInterfaceConstructorReference

Meta issue: KT-8575
Review: https://jetbrains.team/p/kt/reviews/9595

UnsupportedSyntheticCallableReferenceChecker only existed for K1,
because we wanted to release the feature for 1.9 and the feature should
have been working for K2 unconditionally. But since, we're postponing
the release until 2.1, we also need to port the checker from K1 to K2
2023-04-17 17:42:01 +00:00
Marco Pennekamp 567abd2a1c KT-57207 Implement JavaClassFinder.findClasses
- This change is a prerequisite for allowing combined Java symbol
  providers (in LL FIR) to correctly disambiguate classpath order after
  getting classes with a combined scope, as the index access of the
  combined Java symbol provider is not guaranteed to return the class
  that should be first based on the original dependency order. To be
  able to disambiguate, a combined Java symbol provider needs access to
  all class candidates the index can find.
2023-04-17 11:07:47 +00:00
Marco Pennekamp 288606868e [FIR] KT-57207 Avoid FirJavaFacade.knownClassNamesInPackage in the IDE
- `FirJavaFacade.knownClassNamesInPackage` cannot be computed in the IDE
  using the current strategy because there are multiple finders and
  there is no `CliFinder`. However, the cache was still used, which
  caused it to be filled with `null` values and additionally caused
  worse performance in `JavaSymbolProvider` due to hash map accesses via
  `hasTopLevelClassOf`.
- Rewriting the strategy is non-trivial as additional indices are needed
  on the IDE side. See KTIJ-24642.
2023-04-17 11:07:46 +00:00
Kirill Rakhman 91adb88eff [K1] Make Volatile diagnostics applicable to kotlin.concurrent.Volatile
#KT-55628
2023-04-04 10:36:39 +00:00
Marco Pennekamp f9785c1050 [LL FIR] KT-57455 Avoid creating optional annotation class providers
- An `OptionalAnnotationClassesProvider` only needs to be created if the
  package part provider may even have optional annotation classes.
- In the IDE case, the package part provider never provides optional
  annotation classes, so especially in the IDE, we can avoid a lot of
  useless symbol providers with this.
2023-03-27 10:38:50 +00:00
Alexander Udalov b1ca9a0f05 JVM IR: extract JvmIrDeclarationOrigin 2023-03-13 13:51:52 +01:00
Alexander Udalov b1d109e7a3 JVM IR: do not use JvmDeclarationOrigin in duplicate signatures
Apparently the client code which reports errors only meaningfully uses
the `descriptor` field of `JvmDeclarationOrigin` in case of JVM IR.
2023-03-13 13:51:52 +01:00
Evgeniy.Zhelenskiy 5b868becf4 [IR] Hide regular class constructor with MFVC parameters
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2023-03-07 21:44:41 +00: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
Mikhail Glukhikh cab0340497 K1: report also TYPE_MISMATCH_WARNING in JvmSyntheticAssignmentChecker
#KT-56061 Fixed
2023-01-31 22:05:18 +00:00
Mikhail Glukhikh 7cc3f7de62 K1: introduce assignment checkers and convert JvmSyntheticAssignmentChecker
Related to KT-56061
2023-01-31 22:05:16 +00: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
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
Vsevolod Tolstopyatov 21fe0e80ff [K2] Report CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR for class hierarchies
Previously it wasn't reported in FIR for ConcurrentHashMap inheritors
because the receiver id hasn't matched CHM.contains id
Fixed by unwrapping origin of the call in case of fake overrides

^KT-55606 fixed
2023-01-17 09:46:25 +00:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Alexander Udalov 725c066c78 Kapt: dump declaration origins produced by backend
This will be useful in diagnosing behavior differences between JVM and
JVM_IR versions of kapt.
2023-01-13 02:38:40 +01: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 6234da4c86 K1: add use-site diagnostic about property shadowing by a field
Related to KT-50082
2023-01-09 21:37:21 +00:00
Pavel Kunyavskiy 4928e284f6 Make LateinitIntrinsicApplicabilityChecker warning for Native and JS
This checker was enabled only on JVM by mistake.
It's now fixed, but we don't want to make it an error in minor release.
So it will be an warning in 1.8.20 and an error in 1.9.0

^KT-27002
2022-12-20 20:06:52 +00:00
Alexander Udalov 60d96b7d15 Remove some leftover imports of unsafe cast functions 2022-12-06 19:44:56 +00:00
Evgeniy.Zhelenskiy fa4ceb4ef4 [IR] Add diagnostics to forbid annotations for MFVC-typed elements
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:39 +00:00
Hung Nguyen cdbbead157 Handle changes to inline functions/property accessors with @JvmNames
If we detect a change in an inline function `foo` with @JvmName
`fooJvmName`, we have two options:
   1. Report that function `foo` has changed
   2. Report that method `fooJvmName` has changed

Similarly, if we detect a change in an inline property accessor with
JvmName `getFoo` of property `foo`, we have two options:
   1. Report that property `foo` has changed
   2. Report that property accessor `getFoo` has changed

The compiler is guaranteed to generate `LookupSymbol`s corresponding to
option 1 when referencing inline functions/property accessors, but it is
not guaranteed to generate `LookupSymbol`s corresponding to option 2.
(Currently the compiler seems to support option 2 for *inline*
functions/property accessors, but that may change.)

Therefore, we will choose option 1 as it is cleaner and safer.

^KT-54144 In progress

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress

Extract KotlinClassInfo to a separate class

to reduce the size of IncrementalJvmCache and prepare for the next
change.

^KT-54144 In progress

Ignore inline functions that are not found in the bytecode

^KT-54144 In progress

Add unit test for handling `@JvmName`s

Test: KotlinOnlyClasspathChangesComputerTest
             #testFunctionsAndPropertyAccessorsWithJvmNames
^KT-54144 Fixed

Update unit tests for handling `@JvmName`s

In a previous commit, we made a behavior change for inline property
accessors: The existing behavior is that if the implementation of an
inline getter has changed, only usages of the getter will be impacted
but not usages of the setter (and vice versa).

After that previous commit, usages of *both* the getter and setter will
now be impacted (i.e., we might compile slightly more files). This is
because a change to either the getter or the setter will now be
considered a change to the property, which will help simplify our change
analysis.

This commit updates the relevant unit tests to reflect the new behavior.

Test: Updated Incremental*TestGenerated.PureKotlin#testInlinePropertyInClass
      and Incremental*TestGenerated.PureKotlin#testInlinePropertyOnTopLevel

^KT-54144 Fixed
2022-11-10 10:03:55 +01:00
nataliya.valtman 9b212cfa86 Revert "Extract KotlinClassInfo to a separate class"
This reverts commit ec3da62672.
2022-11-07 13:59:32 +01:00
Hung Nguyen ec3da62672 Extract KotlinClassInfo to a separate class
to reduce the size of IncrementalJvmCache and prepare for the next
change.

^KT-54144 In progress

Handle changes to inline functions/property accessors with `@JvmName`s

If we detect a change in an inline function `foo` with @JvmName
`fooJvmName`, we have two options:
   1. Report that function `foo` has changed
   2. Report that method `fooJvmName` has changed

Similarly, if we detect a change in an inline property accessor with
JvmName `getFoo` of property `foo`, we have two options:
   1. Report that property `foo` has changed
   2. Report that property accessor `getFoo` has changed

The compiler is guaranteed to generate `LookupSymbol`s corresponding to
option 1 when referencing inline functions/property accessors, but it is
not guaranteed to generate `LookupSymbol`s corresponding to option 2.
(Currently the compiler seems to support option 2 for *inline*
functions/property accessors, but that may change.)

Therefore, we will choose option 1 as it is cleaner and safer.

^KT-54144 In progress

Ignore inline functions that are not found in the bytecode

^KT-54144 In progress

Add unit test for handling `@JvmName`s

Test: KotlinOnlyClasspathChangesComputerTest
             #testFunctionsAndPropertyAccessorsWithJvmNames
^KT-54144 Fixed

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress

Small cleanup in IncrementalCompilerRunner

 - Add comment for closing caches
 - Rename providedChangedFiles to changedFiles
 - Tiny clean up in `performWorkBeforeCompilation`
 - Count directories to delete in debug logs

^KT-53015 In progress
2022-11-07 13:10:02 +01:00
pyos 6c6d653e85 FE: don't lose annotations on Java primitive arrays
but only use them to enhance for warnings for now.

^KT-48861 Fixed
2022-10-26 09:33:40 +02:00
Mikhail Glukhikh 80fa765333 K1: introduce synthetic assignment checker with deprecation for KT-54305
#KT-54305 Fixed
Related to KT-54309
2022-10-25 12:33:09 +00:00
Ilya Muradyan 8d12342fc6 Add option for skipping calculating all names for optimizing reasons in LazyImportScope 2022-10-20 16:00:42 +02:00
Dmitriy Novozhilov d423782fac [FE 1.0] Remove usages of safeAs and cast from most of FE 1.0 modules:
- :core:descriptors
- :core:descriptors.jvm
- :core:deserialization
- :compiler:cli
- :compiler:frontend
- :compiler:frontend:cfg
- :compiler:frontend.java
- :compiler:frontend.common.jvm
- :compiler:psi
- :compiler:resolution
- :compiler:resolution.common
- :compiler:resolution.common.jvm
- :kotlin-reflect-api
2022-10-12 13:58:56 +00:00
Pavel Mikhailovskii f4bdf54601 KT-8575 Fix warnings for Java synthetic properties 2022-10-10 22:03:58 +00:00
Nikolay Lunyak b6f950ed75 [FIR][FE 1.0] KT-47933: Warn about redundant @Repeatable
Merge-request: KT-MR-7318
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2022-10-07 13:33:49 +00:00
Hung Nguyen 03f83ff339 New IC: Include inline property accessors in class/package members
Problem: ClasspathChangesComputer (a core component of the new IC) uses
the existing inline function analysis from the old IC
(IncrementalJvmCache.InlineFunctionsMap). If an inline property accessor
has changed, the inline function analysis will report the name of the
property accessor, not the name of the property.
ClasspathChangesComputer doesn't see the property accessor's name in the
list of class/package members, so it will throw an exception.

Solution: There are 2 options:
  1. If an inline property accessor has changed, the inline function
     analysis can report the name of the property instead of the
     property accessor.
  2. ClasspathChangesComputer can include property accessors in the list
     of class/package members.

In this commit, we will choose option 2 as it is simpler.

Test: New KotlinOnlyClasspathChangesComputerTest.testPropertyAccessors

Small cleanup - PLS SQUASH INTO PREVIOUS COMMIT

  - Address review
  - Fix failed tests
  - Add some trivial changes

^KT-53871 Fixed
2022-09-19 11:50:08 +02:00
Mikhail Glukhikh fb9b1ad0dc K1: implement warning for upper bound violated in type alias constructors
Partially implements KT-47473
2022-09-15 08:51:46 +00:00
Mikhail Glukhikh b19832ef9a K1: modify error message of ENUM_DECLARING_CLASS_DEPRECATED
Related to KT-53805
2022-09-12 10:45:23 +00:00
Mikhail Glukhikh 769a2ca9b1 K1: report ENUM_DECLARING_CLASS_DEPRECATED on enum entry properly
#KT-53807 Fixed
2022-09-12 10:45:23 +00:00
Dmitriy Novozhilov 671083c701 [Serialization] Implement serialization checker for K2 version of plugin
^KT-53178 Fixed
2022-09-07 07:57:38 +00:00
Pavel Kirpichenkov 24dcad0d9c [MPP] Use module's type checker for upper bound checks
The default type checker doesn't have a correct type refinement setup.
This can cause false positives in subtyping of upper bounds in edge
cases with expect type arguments.

See the tests in the intellij repo.

KTIJ-22295
2022-09-01 09:51:11 +00:00
Pavel Kirpichenkov 029bb55157 [MPP] Refine scope for synthetic Java properties
Unrefined member scopes might have missing Java supertypes and cause
false positive resolution errors for synthetic properties in IDE.

KTIJ-22345
2022-08-25 09:17:46 +00:00
Dmitry Gridin 4f18e7091b [light classes] analysis-api-fir: migrate from :compiler:backend to :compiler:backend.common.jvm
^KT-53097
2022-08-01 13:56:35 +00:00
Denis.Zharkov 7d6e133c0d Refine warning messages for KT-36770
^KT-36770 Fixed
2022-07-25 16:08:49 +00:00
Denis.Zharkov a3b33901d8 Add issue link to deprecation warning message for KT-36770
^KT-36770 Fixed
2022-07-22 16:42:13 +00:00
Dmitriy Novozhilov af8caae387 [KAPT] Fix formatting 2022-07-20 10:12:25 +00:00