Commit Graph

105364 Commits

Author SHA1 Message Date
Dmitriy Novozhilov 3d6ec0ec75 [FIR2IR] Automatically store IR declaration in its parent upon creation
Previously, creating a declaration with Fir2IrCallableDeclarationsGenerator/
  Fir2IrClassifiersGenerator didn't guarantee that this declaration will
  be actually added to the list of parent class/file declarations, which
  lead to situations when FIR2IR created some declarations in the air
  (mostly fake-overrides)
2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 22f55b3dc4 [Raw FIR] Keep the name of an anonymous object of enum entry in classId of its nested classes
It is needed to have an ability to distinguish those two cases in FIR2IR:

Without this change the following tests fail:
- org.jetbrains.kotlin.test.runners.codegen.FirPsiBlackBoxCodegenTestGenerated.Enum
  - testEnumEntryReferenceFromInnerClassConstructor1()
  - testEnumEntryReferenceFromInnerClassConstructor2()
  - testEnumEntryReferenceFromInnerClassConstructor3()
  - testInnerClassMethodInEnumEntryClass()
  - testInnerClassMethodInEnumEntryClass2()
  - testKt9711_2()
  - testDeepInnerClassInEnumEntryClass()
  - testKt7257_boundReference1()
  - testInnerClassInEnumEntryClass()
  - testKt44744_innerClass()
2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 000c24fc69 [Raw FIR] Add test for callable ids of functions inside body of enum entry 2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 34d0f3dbc2 [FIR2IR] Correctly calculate ir origin for f/o callables in declarations generator
This change uncovers one problem, which causes some MPP tests to fail
This problem will be fixed in further commits

Uncovers KT-62535
2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 50425e82c5 [FIR2IR] Simplify Fir2IrDeclarationStorage.getIrPropertySymbol
For reasoning refer to the message of the previous commit
It is the same as for `getIrFunctionSymbol`

There is one failing test here, caused by KT-61941
The issue was here before this commit, but it was hidden
2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov 1e090d45d1 [FIR2IR] Simplify Fir2IrDeclarationStorage.getIrConstructorSymbol
For reasoning refer to the message of the previous commit
It is the same as for `getIrFunctionSymbol`
2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov c7c83de528 [FIR2IR] Don't create fake-overrides of static members like they are real ones
It's incorrect to create fake-overrides with `getOrCreateIrFunction/Property`
  call. FakeOverrideGenerator should be used instead. So this commit
  just changes the place which creates static f/o generated from

I failed to reproduce the corresponding failure in compiler tests, but
  without this change FP Kotlin test fails
2023-10-17 12:46:27 +00:00
Dmitriy Novozhilov bb093037c0 [FIR2IR] Simplify Fir2IrDeclarationStorage.getIrFunctionSymbol
Previously `getIrFunctionSymbol` effectively did the same thing as `getOrCreateIrFunction`,
  but in a slightly different way. To avoid logic duplication and source of
  potential inconsistencies, implementation was changed to just delegate to
  `getOrCreateIrFunction`

Changes in `computeIrOrigin` were required because origin for callables in
  `getOrCreateIrFunction` and `getIrFunctionSymbol` was computed differently,
  so `computeIrOrigin` was changed to preserve existing behavior

^KT-60924
2023-10-17 12:46:27 +00:00
Sebastian Sellmair a8e637205c [Gradle] Migrate extraProperties.getOrPut usages to *StoredProperty
KT-61634
2023-10-17 12:10:15 +00:00
Sebastian Sellmair ecbd741e40 [Gradle] Rename stored{Classifier}Property to {classifier}StoredProperty
This change is intended to improve the intuition of developers.
After adding the two functions, many times developers (me) have
tried to use the 'wrong' (which is now the new name) function name.

KT-61634
2023-10-17 12:10:15 +00:00
Sebastian Sellmair 08241acb6f [Gradle] Demote ExtrasProperty APIs with little usage
Those APIs can either be replaced with StoredProperty
Some APIs also have shown to be 'hard to understand'

KT-61634
2023-10-17 12:10:15 +00:00
Vladimir Sukharev 242c1cf5f0 [FIR] Fix disappeared REPEATED_ANNOTATION for dynamic types
https://youtrack.jetbrains.com/issue/KT-59916/K2-Disappeared-REPEATEDANNOTATION
FirAnnotationChecker does not detect repeated annotation on dynamic type, since FirTypeResolverImpl wrongly did not convert source annotations to attributes of ConeDynamicType.
This MR improves FirTypeResolverImpl to convert attributes of FirDynamicTypeRef to annotations and attach them to ConeDynamicType.

Merge-request: KT-MR-12551
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-17 10:18:36 +00:00
Ilya Goncharov 22a01432df [Gradle,JS] Remove legacy target in Gradle plugin
This reverts commit 4c82206d

^KT-60694 fixed
2023-10-17 09:42:38 +00:00
Alexander Shabalin 27c85a059f [K/N] Move memmem from Porting.h to KString.cpp ^KT-59008 2023-10-17 09:37:34 +00:00
Dmitrii Gridin d9071aed78 [LL FIR] LLFirAnnotationArgumentsTargetResolver: add missing context for value parameters 2023-10-17 09:30:44 +00:00
Mikhail Glukhikh fd057ac68a FE: Add two more tests around KT-59561 2023-10-17 06:49:38 +00:00
Mikhail Glukhikh 9f6abfc166 K2/MPP: treat Array<Some> & Array<out Some> as similar types in annotations
#KT-59561 Fixed
Related to KT-61100
2023-10-17 06:49:38 +00:00
Mikhail Glukhikh f085d0f660 K2: add reproduction of KT-61100 and KT-59561 2023-10-17 06:49:37 +00:00
Sergej Jaskiewicz 7ab4ca6f51 [IR generator] Inherit Element from AbstractElement
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-16 22:56:36 +00:00
Sergej Jaskiewicz f9d17a2d51 [IR generator] Inherit Field from AbstractField
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-16 22:56:36 +00:00
Sergej Jaskiewicz 15751333e3 [IR generator] Introduce constants for List-like types 2023-10-16 22:56:36 +00:00
Ilya Goncharov 4e37ac6ed8 [JS] Silent rollup build
^KT-53077 fixed
2023-10-16 21:20:49 +00:00
Alexander Udalov 6219f7fc0d JVM IR: fix detection of enum entries in the same module
Use the new `IrClass.hasEnumEntries` flag added in the previous commit.

 #KT-61208 Fixed
2023-10-16 20:22:20 +00:00
Alexander Udalov c33c918bd4 IR: add IrClass.hasEnumEntries
This flag will be used on JVM to determine whether or not to generate
external enum entries mappings ("$EntriesMappings") classes. Note that
from the frontend's point of view, every enum has `entries`, so for
backend purposes we have to reach out to the underlying deserialized
data to read the flag from the metadata.
2023-10-16 20:22:20 +00:00
Alexander Udalov db31f1f926 Tests: update some backend tests on enum entries
The enumEntriesIntrinsicMultipleEnums.kt test was supposed to check that
JVM backend generates 3 `$EntriesIntrinsicMappings` classes: for X, for
Y, and for Z. Mappings classes are generated for enums without
`entries`, i.e. Kotlin enums compiled without `EnumEntries` language
feature, and Java enums. The test incorrectly _enabled_ the language
feature for X though, and `$EntriesIntrinsicMappings` for X was
generated anyway because of KT-61208.

To keep the original intention of the test, I'm disabling the language
feature for X, so that it will be considered as enum without `entries`.
KT-61208 will be fixed in a separate commit (with separate tests).

The boxInline and bytecodeText tests changed their meaning when language
feature EnumEntries started to be enabled by default, so those changes
are a continuation to ebd43fc8c0. The behavior did not change after
enabling the feature, once again because of KT-61208.

Also, remove obsolete error suppressions which are no longer needed
after 64c8ce18a0.
2023-10-16 20:22:20 +00:00
Roman Golyshev cb65d2420f KTIJ-27139 [AA] Clean-up KtFirReferenceShortener
Unify the code which detects whether qualified expression/type is
actually selected
2023-10-16 20:05:01 +00:00
Roman Golyshev d2fcd71d23 KTIJ-27139 [AA] Shorten qualified expressions only when the callee/type reference is in selection
If you want to shorten call like `foo.bar()` into `bar()`, then you
need your range to intersect with `bar` callee reference. Having only
`foo` in the range is not enough

Same goes for the type references - to shorten `foo.Bar` into `Bar`, you
need at least some intersection of your range with `Bar` reference

^KTIJ-27139 Fixed
^KTIJ-27015 Fixed
2023-10-16 20:05:01 +00:00
Hung Nguyen ecbf69504a [IC] Add back flush() API to PersistentStorage
In commit 4e89dcf, we removed `flush()` from `PersistentStorage`
(previously called `LazyStorage`) because it is not used in Gradle
builds.

However, `flush()` is still used in JPS builds, so we need to add that
API back in this commit.

#KT-62486 Fixed

Co-authored-by: Hung Nguyen <hungnv@google.com>


Merge-request: KOTLIN-MR-796
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2023-10-16 18:30:47 +00:00
Ivan Kochurkin 498f2e534a [FIR] Don't enhance Int and String Java final static fields
It's effectively a breaking change (^KT-62558)

K2 assigns flexible type to all static fields (from Java) and, for example,
`String? becomes String unlike K1. It affects IR signature generating.
That's why signature dump is disabled for some tests.

^KT-57811 Fixed
^KT-61786 Fixed
2023-10-16 17:16:56 +00:00
Ivan Kochurkin 2d61b9a477 [FIR] Elvis operator: flexible rhs type implies flexible type of whole elvis
It's required for further removing of enhancement of final static fields

Also, it's k2-potential feature

^KT-62467 Fixed
2023-10-16 17:16:56 +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
Dmitrii Gridin 15cdc971bf [FIR] FirAnnotationArgumentsMappingProcessor: pass correct phase 2023-10-16 15:30:44 +00:00
Dmitrii Gridin 976fb7d093 [LL FIR] support lazy resolution for synthetic properties and accessors
Such declarations are just wrappers, so we should delegate
resolution to the original declarations

^KT-61990 Fixed
2023-10-16 15:07:11 +00:00
Dmitrii Gridin 2d1d5fb3a8 [LL FIR] add missed check to getDesignationsToResolveRecursively
^KT-61990
2023-10-16 15:07:11 +00:00
Dmitrii Gridin b8000d611a [FIR] FirSyntheticProperty: drop resolveState
Such properties should be stateless and just wrap over accessories.
Logic inside contract transformer is unreachable because we do not
allow lazy resolution for synthetic properties.

^KT-61990
2023-10-16 15:07:11 +00:00
Dmitrii Gridin bb40ce0bfc [FIR] FirSyntheticProperty: make constructor internal
Also, backingField can be moved into the body

^KT-61990
2023-10-16 15:07:11 +00:00
Dmitrii Gridin 6c1405cf99 [FIR] FirResolvePhaseRenderer: change format for FirSyntheticPropertyAccessor
^KT-61990
2023-10-16 15:07:11 +00:00
Dmitrii Gridin 5de269147f [LL FIR] add tests for synthetic property
^KT-61990
2023-10-16 15:07:11 +00:00
Sebastian Sellmair 670b46fe15 Add .fleet to CODEOWNERS 2023-10-16 13:48:21 +00:00
Sebastian Sellmair f001f35230 Initial shared settings.json for fleet
This will check in a workaround necessary for FL-22276
2023-10-16 13:48:21 +00:00
Ilya Goncharov 6de4d99706 [JS] Drop publishing JAR artifact of kotlin-stdlib-js
^KT-62067 fixed
2023-10-16 13:34:37 +00:00
Ilya Goncharov 51c6e81de9 [JS] Drop publishing JAR artifact of kotlin-test-js
^KT-62067 fixed
2023-10-16 13:34:37 +00:00
Ilya Goncharov e9cc2931cc [JS] Use kotlin-stdlib-js.klib instead of *.jar 2023-10-16 13:34:37 +00:00
Ilya Goncharov a79324037d [JS] Fix JPS artifacts cordinates 2023-10-16 13:34:37 +00:00
Ilya Goncharov 1cde8c3624 [JS] Fix kotlin bom to use type klib 2023-10-16 13:34:37 +00:00
Ilya Goncharov 1b7e7dfed7 [JS] Fix JS artifacts in maven build 2023-10-16 13:34:36 +00:00
Alexander Udalov 9fd1445631 JVM: use metadata version 1.9 for .kotlin_module if LV=2.0
See the comment in the code for more info.

No proper test added because the compiler test infrastructure lacks the
ability to run old compiler versions, however I've verified manually
that the change fixes the issue.

 #KT-62531 Fixed
2023-10-16 12:45:47 +00:00
Dmitriy Novozhilov d5540ff035 [IR Actualizer] Don't report errors about not implemented members from actualizer
Reporting of those errors was implemented as an ad-hock solution for part
 of the KT-58881, and it was implemented incorrectly. There won't be any
 need in this reporting in actualizer after KT-58881 will be fixed, so
 there is no actual sense to fix their implementation in actualizer itself
 (as it will be removed)
2023-10-16 12:26:31 +00:00
Alexander Udalov 2788dcb5ff K2: resolve remove(Int) clash in JavaOverrideChecker
In Kotlin subclasses of `MutableCollection<Int>`, the method
`remove(Int)` has its argument boxed, so that it wouldn't clash with the
method from `java.util.List`. So `JavaOverrideChecker` should understand
that a Java method `boolean remove(java.lang.Integer)` overrides it,
otherwise platform declaration clash was reported.

The code is adapted from `forceSingleValueParameterBoxing` in K1's
`methodSignatureMapping.kt`.

The test has been moved and adapted from diagnostic to codegen box
tests, to check correct backend execution + runtime.

 #KT-62316 Fixed
2023-10-16 11:26:58 +00:00
Roman Efremov 8e023edc4f [K2] Add TODO for KT-62559 (prevent reporting ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
...twice in CLI mode in K2).

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00