Commit Graph

105339 Commits

Author SHA1 Message Date
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
Roman Efremov 0fd700de21 [FIR] Fix case with lazy resolve in expect-actual annotation checker
Unresolved annotation arguments were treated as absent arguments,
which lead to false-positive reports.
Add assert and test for that and fix.

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00
Roman Efremov 4c75fb108f [Test] Add test for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic
...when annotations arguments are lazily resolved.

MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Roman Efremov 423f4ca5f0 [FE, IR] Check compatibility of annotations set on type usages in expect and actual declarations
This includes checking of annotatins set on:

- value parameter types
- type parameter bound types
- extension functions receiver types
- function return types
- class super types

Fix in `defaultParams_inheritanceByDelegation_positive.kt`
is needed because of problem in resolution of implicit return types
(KT-62064), which leads to crash in annotation checker, because it
expects resolved return type.

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00
Roman Efremov cb8529d65b [Test] Add tests for annotations set on type usages in expect and
...actual declarations.

 MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Roman Efremov fbdc64cdad [FIR] In tree generator make it possible to add custom super types
...to element.

MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Roman Efremov ab2c129466 [FE, IR] Refactor: extract compatibility check of two annotation lists to separate method
This is needed for subsequent checks of annotations
set on types, while currently method accepts only
declarations.

MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Vladimir Dolzhenko d092e99ae8 Drop KtStubElementTypes#FILE
It has been marked as deprecated for a while and targeted to be deleted in 1.9.0

#KT-53781
2023-10-16 10:44:08 +00:00
Anna Kozlova 3c2be4551b [AA] getExpectedType should not calculate expression type
if property doesn't specify explicit type,
property's return type would be calculated by provided initializer

^KT-62588 fixed


Merge-request: KT-MR-12564
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-10-16 09:31:52 +00:00
Vladimir Sukharev 16dfc6df71 [FIR] Missing NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE
^KT-59433 Fixed
2023-10-16 09:08:23 +00:00
Vladimir Sukharev da1fa8fce4 [FIR] Revert: Fix K2: Introduced AMBIGUOUS_ANONYMOUS_TYPE_INFERRED
This reverts commit d7adc0ce32.


Merge-request: KT-MR-12569
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-16 09:05:58 +00:00
Dmitrii Gridin 90102ad8b7 [LL FIR] avoid body resolve during getOrBuildFir for super types
This also covers a case with annotations on a super type entry

^KT-61789 Fixed
2023-10-13 17:13:14 +00:00
Dmitrii Gridin 515e05cd94 [LL FIR] add test for getOrBuildFir for super type
^KT-61789
2023-10-13 17:13:14 +00:00
Dmitrii Gridin 4d29d6e3b4 [LL FIR] FileStructure: accurate processing of generated declarations inside classes
We should process generated property as a part of the primary constructor.
This was already implemented in 8387ea8a, but some parts were missed.

ClassDiagnosticRetriever:
* dropped relation to properties generated from constructor parameters
as they should belong to the primary constructor only
* accurate logic to fully visit an implicit primary constructor to be
able to process nested declarations (e.g., inside a super type call)

SingleNonLocalDeclarationDiagnosticRetriever:
* add relation to generated properties as now they fully belong to
the constructor

FileElementFactory:
* dropped explicit resolution of generated properties from a constructor
* added explicit resolution of generated enum members for consistency.
Effectively, this is not required because we don't have compiler
checkers for such generated enum member declarations

ClassDeclarationStructureElement:
* do not collect mapping for generated properties from constructor
* explicitly declare that we should process only ClassDelegationField

^KT-62437 Fixed
2023-10-13 17:13:14 +00:00
Dmitrii Gridin 1a01dd4dd4 [Analysis API] add diagnostic tests for unresolved reference inside primary constructor
^KT-62437
2023-10-13 17:13:14 +00:00
Yan Zhulanow 45a59f0a55 [LL API] Filter duplicating compiled callables inside FirSymbolProvider
Before the code fragment analysis was extracted to the separate module,
it was impossible to modify the symbol provider, so a conflict resolver
was patched instead. The solution was not complete, though, as it only
covered call resolution ambiguities. The compiler sometime calls a
symbol provider directly, like it's done in 'BuiltinSymbolsBase'.

Relevant tests are in the IntelliJ project (see singleBreakpoint/
conflictingStdlib.kt).

^KTIJ-27329 Fixed
2023-10-13 17:07:03 +00:00
strangepleasures ac51e7b407 KT-61628 [KAPT] Re-enable testAndroidDaggerIC in K2 2023-10-13 16:23:14 +00:00
Mikhail Glukhikh bf65297d48 FIR2IR: make both 'multiplexing' offset-conversion functions not inline
This commit prevents duplication of lambda source code while inlining
offset-conversion functions.
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh f501c3870d FIR2IR: make source range for implicit invoke call similar to PSI2IR 2023-10-13 15:42:58 +00:00
Mikhail Glukhikh fe979cc822 K2: add source range test with extension lambda call
This test is equivalent to IDE debugger test
testNoParameterExtensionLambdaArgumentCallInInline3,
which changes behavior due to previous commit
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh b7b7dd1000 FIR2IR: make sources of qualified accesses & calls closer to PSI2IR
#KT-60111 Fixed
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh 7c66a3dc65 Add source range test around multi-line calls 2023-10-13 15:42:58 +00:00
Mikhail Glukhikh 0fb4c9b4fe FIR2IR: generate specific sources for property accessors
Related to KT-60111
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh f38b8fd8cb K2: reproduce KT-60111 2023-10-13 15:42:58 +00:00
Mikhail Glukhikh c4ec576a99 FIR2IR: make *Assign call origins closer to PSI2IR
#KT-60261 In Progress
2023-10-13 15:42:58 +00:00
Mikhail Glukhikh 13ae4abe52 FIR2IR: use elvis temporary variable name closer to PSI2IR
Related to KT-61983
2023-10-13 15:42:57 +00:00