Commit Graph

330 Commits

Author SHA1 Message Date
Wojciech Litewka 2ed0ffd123 [IR] Autogenerate IrExternalPackageFragmentImpl
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Dmitriy Novozhilov d9beae0556 [Test] Change indent from four to two spaces in generated tests
This is needed to reduce the size of generated test files, which started
  to exceed default IDE limit
2024-02-16 12:48:24 +00:00
Sergej Jaskiewicz 2096d22e18 [IR] Mark IrBlockBodyImpl with an opt-in annotation
KT-59318
2023-12-19 16:20:02 +00:00
Sergej Jaskiewicz f844a86057 [utils] Introduce the bind function and use it throughout 2023-12-13 10:04:45 +00:00
Sergej Jaskiewicz c5f519f7c7 [FIR/IR generator] Commonize visitor printing logic
This is a step towards commonizing the code generator between
FIR and IR: KT-61970

Also, don't use kotlinpoet for generating IR visitors (KT-61703)
2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz aaf7ccbebd [util] Introduce IndentingPrinter interface
This interface is more convenient to pass around so that it's easier
to replace different printer implementations.
2023-10-25 13:04:15 +00:00
Sergej Jaskiewicz 895d107ac5 [util] Convert Printer from Java to Kotlin 2023-10-25 13:04:14 +00:00
Sergej Jaskiewicz c442d0e159 [util] Rename Printer.java to Printer.kt before converting it to Kotlin
This is to preserve the Git history of the file.
2023-10-25 13:04:14 +00:00
Roman Golyshev 648330da50 [kotlin] Make SmartSet implement MutableSet for more type-safety
`AbstractSet` is a java class, and it brings flexible types with it.
Because of it, it was possible to write the following code:

```kt
fun usage() {
  val mySet = SmartSet.create<String>() // should not contain nulls
  mySet += null // compiles because of flexible types
}
```

Using `AbstractMutableSet`
as a base class does not change the implementation,
but explicitly adds a proper kotlin `MutableSet`
interface to the class, making it more type-safe
2023-10-16 16:25:17 +00:00
Nikita Bobko 91a337074e Refactoring: Improve createExpectActualTypeParameterSubstitutor API
Review: https://jetbrains.team/p/kt/reviews/12279/files

Motivation: make sure that cases like KT-62027 won't happen again
Review: https://jetbrains.team/p/kt/reviews/12279/files

Now it's responsibility of the
`createExpectActualTypeParameterSubstitutor` calller to think about the
case when parameters size isn't equal. You must not be able to create a
substitutor if type parameters sizes are not equal

Improvement in `createExpectActualTypeParameterSubstitutor` API also
improves
`AbstractExpectActualCompatibilityChecker.getCallablesCompatibility`
API.

Because suppose that you accidentally created a redundant wrapping
substitutor => you need to handle the case of not equal type parameters
size on the call site => you start thinking why you should do that on
the call site? It must be a responsibility of
`getCallablesCompatibility` => you realize that you created a redundant
wrapping substitutor
2023-10-10 09:02:07 +00:00
Artem Kobzar 878452bd2b [K/JS] Implement file merging for clashed file during per-file compilation 2023-09-14 13:14:15 +00:00
Sergej Jaskiewicz 56cb0bf071 [utils] Move atMostOne to core/util.runtime
There is nothing backend-specific about this helper function.
2023-09-13 14:25:08 +00:00
Iaroslav Postovalov 059046a2b1 [JVM] Micro-optimize method signature mapping
This commit optimizes functions related to method signature mapping on
the JVM backend. The most significant change is avoiding re-allocations
in StringBuilder when building internal names. The commit also includes
minor optimizations, such as removing redundant allocations of strings
and other objects.
2023-09-01 20:26:17 +00:00
Nikolay Lunyak 61448531cb [FIR] Support MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES
^KT-59408 Fixed
2023-08-04 11:20:39 +00:00
Dmitrii Gridin 82061a73eb [util] SmartPrinter: override toString to print content instead of identity hash
Otherwise, all current exceptions contain only something like SmartPrinter@1234
2023-07-21 12:40:00 +00:00
Ilya Kirillov 25911b1fec Move SmartPrinter to kotlin.core.util.runtime so it's accessible from KotlinExceptionWithAttachments 2023-07-18 11:49:20 +00:00
Abduqodiri Qurbonzoda 7346cf4777 Introduce jdk-api-validator to ensure kotlin-reflect uses jdk6 API
Merge-request: KT-MR-6930
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-07-12 05:13:08 +00:00
Dmitriy Novozhilov d3a098e7ef [FIR] Remove redundant TODOs from FirSamResolver 2023-07-05 08:25:42 +00:00
Artem Kobzar 64158a8a2f [K/JS] Add file-to-file compilation ^KT-6168 Fixed 2023-06-22 18:23:45 +00:00
Vladimir Dolzhenko 05652e7d8d Improve exception handling and reporting
#KT-59445
2023-06-22 14:14:18 +00:00
Dmitriy Novozhilov b26b649d4e [FE] Introduce commonized version of expect/actual compatibility calculator
This is needed to use the same code for those checks between
  both frontends and backend

^KT-58578
2023-05-19 10:19:17 +00:00
Yahor Berdnikau eb4e96a113 Add kotlin-build-tools-enum-compat workaround
It acts as a workaround for the case when build tools or dependencies
are compiled with latest 'kotlin-stdlib' version, but at a runtime older
 'kotlin-stdlib' is provided, which does not know about new
 `EnumEntries`.

 ^KT-57317 Fixed
2023-04-21 14:57:17 +00:00
Artem Kobzar 33c5068b79 [K/JS] Rework IR deserialization and lowering phases to consume less memory 2023-04-19 13:10:19 +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
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 a9248569a6 [FIR] Fix reporting of UNINITIALIZED_ENUM_ENTRY in init blocks
^KT-41126 Fixed
2023-02-10 12:30:12 +00:00
Dmitriy Novozhilov bd26c29229 [FIR] Resolve arguments of error types during type resolution 2023-01-12 17:45:06 +00:00
Dmitriy Novozhilov aaf0a1f396 [FIR] Introduce shouldNotBeCalled utility function 2022-12-01 07:29:38 +00:00
Dmitriy Novozhilov 01c6c7dc59 [FIR] Properly approximate return type of callable declarations
- approximate intersection types in all non-local declarations
- approximate local types in non-private non-local declarations
2022-11-22 15:46:20 +00:00
Dmitriy Novozhilov 9b63dde1c3 Add error-level OptIn on safeAs, cast and assertedCast functions in addToStdlib
Usage of this function is unsafe because it does not have native compiler
  support. This means that compiler won't report UNCHECKED_CAST,
  CAST_NEVER_SUCCEED or similar diagnostics in case of error cast
  (which can happen immediately or after some refactoring of class hierarchy)
2022-10-06 06:57:07 +00:00
Abduqodiri Qurbonzoda 34e50649e8 Switch JVM target of the standard libraries to 1.8 #KT-51907 2022-08-13 01:33:45 +03:00
mcpiroman 529c03ab08 Switch to auto generated IR tree
Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com>
2022-06-13 18:58:05 +02:00
Yahor Berdnikau af6f17c243 Unify kotlinCompilerClasspath for all projects
This will prevent spawning second Kotlin daemon during compilation
except 'buildSrc' compilation. Original change was introduced in
2e515f3945 commit.
2022-05-24 07:58:38 +00:00
Alexander Udalov 2e515f3945 Prohibit JVM target 1.6
But still compile stdlib, reflect, kotlin.test and scripting runtimes
with JVM target 1.6 to simplify migration from Kotlin 1.6 to 1.7.

 #KT-45165 Fixed
2022-04-19 22:54:40 +02:00
Dmitriy Novozhilov 6f64aedaf0 [FIR] Fix FindReferencePositioningStrategy for light tree
There was a problem which causes to lookup for assign token inside
  functions from arguments of call
2022-03-11 15:36:05 +03:00
Dmitriy Novozhilov ccb74b6477 [FIR] Fix computing compatibility of expect and actual modality 2022-02-18 17:44:39 +03:00
Stanislav Erokhin 1326ca674e Introduced IDEAPluginsCompatibilityAPI and returned some API
Please read the description of IDEAPluginsCompatibilityAPI.
Also, you may notice, that Deprecation annotation was removed.
That is because with level ERROR it isn't possible to opt-in
to such API in the legit cases. And with level WARNING it won't be
reported because We have diagnostic with level ERROR about OptIn marker.
Sadly, there is no way to add ReplaceWith to the OptIn marker
2022-01-13 18:03:07 +01:00
Denis.Zharkov a33d9df0cd NI: Support forking inference with heuristics
Mostly, it only affects FIR

It partially allows to consider several variance of constraints like
A<Int> & A<T> <: A<X_var> that are mostly brought by smart casts

^KT-49542 Fixed
^KT-50489 Relates
2022-01-11 20:45:55 +03:00
Ilya Kirillov 25fe14b514 Move PerformanceCounter to runtime utils, so it can be used outside FE1.0 2021-12-27 16:23:07 +03:00
Dmitriy Novozhilov cb0705ec03 [FIR] Change scheme of generating declarations by plugins
Methods `needToGenerateAdditionalMembersInClass` and
  `needToGenerateNestedClassifiersInClass` are removed, now compiler
  uses `get...Names` and `getTopLevel...` methods to determine which
  extension may generate declaration with specific classId/callableId

This is needed to simplify API of FirDeclarationGenerationExtension and
  provide guarantee that `generate...` method will be called with
  specific classId/callableId only if specific extensions returned name
  for this id from `getName...` functions
2021-11-23 15:01:28 +03:00
Denis.Zharkov 019001ca20 Optimize memory footprint related to empty/single element collections
^KT-47926 Related
2021-08-30 16:51:55 +03:00
Ilya Kirillov c17a4a5a3b FIR IDE: move light classes to separate module 2021-08-24 20:13:09 +03:00
Alexander Udalov 0a9498f7e2 Build: suppress deprecated JVM target warning globally
There seems to be no point in configuring the compiler argument per
project. This argument will be deleted soon anyway, when we remove
support for JDK 1.6 & 1.7.

Also remove `disableDeprecatedJvmTargetWarning`. It didn't have any
effect in all modules where it was applied because these modules
reassign `freeCompilerArgs` anyway, with
`-Xsuppress-deprecated-jvm-target-warning` in it.
2021-07-27 13:35:39 +02:00
Dmitriy Novozhilov 8e0793091a Add @NoInfer to safeAs type
This change will force specify type argument of every safeAs call
2021-07-12 10:11:36 +03:00
Victor Petukhov 18384788a4 Move type enhancement state stuff into core:descriptors.jvm 2021-07-06 09:54:29 +03:00
Victor Petukhov 8de05691a9 Revert "Move fqname related stuff into core:util.runtime module"
This reverts commit e651e1c6
2021-07-06 09:54:28 +03:00
Victor Petukhov ea901d81fb Get rid of redundant Jsr305State 2021-07-06 09:54:28 +03:00
Victor Petukhov f46dc713d7 Support rxjava 3 nullability annotations 2021-07-06 09:54:28 +03:00
Victor Petukhov 61c2f1b203 Extract building JSR-305 settings to separate function 2021-07-06 09:54:27 +03:00
Victor Petukhov e16033f8d8 Add androidx recently nullability annotations 2021-07-06 09:54:26 +03:00