Commit Graph

46661 Commits

Author SHA1 Message Date
Alexander.Likhachev a19bd2ed2e [Build] Migrate most of the build logic from Project.buildDir usage
It's going to be deprecated in Gradle 8.3

There's currently no way to pass a `org.gradle.api.provider.Provider` to the JavaExec.systemProperty or Test.systemProperty. There's a workaround using `org.gradle.process.CommandLineArgumentProvider`, but I intentionally don't rework these calls as Gradle is going to allow passing providers to configure system properties: https://github.com/gradle/gradle/issues/12247#issuecomment-1568427242
^KTI-1473 In Progress
2023-12-07 18:31:06 +00:00
Kirill Rakhman 81517a3d29 [FIR] Set targets of annotation classes in FirJavaElementFinder
#KT-60504 Fixed
2023-12-07 18:29:45 +00:00
Kirill Rakhman daa02813c2 [FIR] Generate FIR diagnostics with explicit types
#KT-64147 Fixed
2023-12-07 18:29:28 +00:00
Dmitriy Dolovov c9f4a1a841 IR: Avoid overwriting of property signature descriptions
^KT-64085
^KT-64082
2023-12-07 15:02:24 +00:00
Dmitrii Gridin 97956b4374 [LL FIR] resolve propagated type annotations correctly
This commit is Low Level FIR part of changes around propagated
annotations (aka foreign annotations).
It includes such changes as:
* implicit type phase postpones foreign annotations resolution
* annotation arguments are requests resolution for postponed
annotations from implicit type phase as a pre-resolve step
* body resolve phase just calls lazy resolution for foreign annotations
on demand
* isResolved check for type annotations to be sure that all annotations
are resolved after annotation arguments phase

^KT-63042 Fixed
^KT-63681 Fixed
2023-12-07 12:26:40 +00:00
Dmitrii Gridin cf11e26755 [FIR] do not transform file annotation arguments before annotations phase
^KT-63042
2023-12-07 12:26:40 +00:00
Dmitrii Gridin 9888cbbfcd [FIR] do not transform propagated annotations from place other than declaration side
We shouldn't transform annotations not from declaration side due to
a possible different context and to avoid unexpected transformation of
unrelated declarations

Example:
```kotlin
fun implicitType1() = TopLevelObject.expectedType()

object TopLevelObject {
    private const val privateConstVal = "privateConstVal"
    fun expectedType(): @Anno(privateConstVal) Int = 4
}
```
Here we will try to transform the annotation from `expectedType`
during `implicitType1` and as the result, we will see unresolved
reference on the declaration side. This commit fixes this issue.

This solution is based on the fact that the compiler anyway will
resolve the propagated annotation on the declaration side.
And it doesn't matter if it is resolved before or after the call site
declaration transformation, because as a global result, we will observe
that all declarations are resolved correctly in the right context.

Hence, this commit fixes the issue in the case of "full resolution"
which is true for the compiler, but it is not correct for Low Level
FIR where we resolve declarations on demand. It will be solved in
the next commits

^KT-63042
2023-12-07 12:26:40 +00:00
Dmitrii Gridin 6f0d52f991 [FIR] runAllPhasesForLocalClass: drop redundant annotations transformation
Such annotations will be transformed as usual in `FirDeclarationsResolveTransformer.transformRegularClass`.
Also, this transformation doesn't have a corresponding class as a container

^KT-63042
2023-12-07 12:26:40 +00:00
Dmitrii Gridin a7afd1fe01 [FIR] ReturnTypeCalculatorWithJump: use outer transformer instead of type calculator
This is a more flexible solution

^KT-63042
2023-12-07 12:26:40 +00:00
Dmitrii Gridin edb496f260 [FIR] BodyResolveContext: withFile should add container as well
This container will be used during an annotation call owner search

^KT-63042
2023-12-07 12:26:40 +00:00
Dmitrii Gridin ed7415ab93 [FIR] BodyResolveContext: insideClassHeader should add container as well
This container will be used during an annotation call owner search

^KT-63042
2023-12-07 12:26:40 +00:00
Dmitrii Gridin ec180bca71 [FIR] ImplicitBodyResolveComputationSession: encapsulate compute logic
This is required to simplify the code and have only one enter point

^KT-63042
2023-12-07 12:26:40 +00:00
Dmitrii Gridin 83bdac8d61 [FIR] CustomAnnotationTypeAttribute: drop containerSymbols
Now annotations have the container symbol itself, so this property
is no longer needed.
This migration fixes issues with a missed container symbol, so now
all cases of lazy resolution from KtType are supported

^KT-63042
2023-12-07 12:26:39 +00:00
Dmitrii Gridin 264a151676 [FIR] do not copy annotations during type propagation
We should share the original instance to be able to later resolve it in
the original context. This commit returns the KT-60387 problem, but the
root cause (concurrent modification) will be fixed in the context of
KT-63042

^KT-63042
2023-12-07 12:26:39 +00:00
Dmitrii Gridin 69559689fd [LL/FIR] add more resolve tests for declarations with annotations
^KT-63042
2023-12-07 12:26:39 +00:00
Dmitrii Gridin 5bd1a97632 [FIR] LT builder: extract convertAnnotationList from convertModifierList
To simplify the logic around `convertModifierList` as a combination of
annotations and modifiers doesn't work well

^KT-63042
2023-12-07 12:26:39 +00:00
Dmitrii Gridin c5cba4c053 [FIR] builder: provide containingDeclarationSymbol
We cannot use only non-local declarations as anchors due to the same
resolution logic between member declarations of local classes, so we
have to support such cases as well

^KT-63042
2023-12-07 12:26:39 +00:00
Dmitrii Gridin be4bc81b1b [FIR] FirFileSymbol: add stable toString
It will be used in tests in the next commit

^KT-63042
2023-12-07 12:26:39 +00:00
Dmitrii Gridin 6eca9fe3a9 [FIR] tree: introduce containingDeclarationSymbol for annotation calls
This symbol will be used during resolution to avoid transformation
of annotations in the wrong context in the case of FIR node sharing.
The symbol should be some containing declaration symbol to be able
to answer the question "Are we own this annotation?" during resolution

^KT-63042
2023-12-07 12:26:39 +00:00
Dmitrii Gridin 1d5ab8c24f [FIR] builder: more tests for annotations
^KT-63042
2023-12-07 12:26:39 +00:00
Xin Wang 11749d7c89 [Codegen][JVM]: Mark line number before invoking intrinsics
Fixes #KT-61768
2023-12-07 11:54:12 +00:00
Nikita Nazarov 0898dd1e7f [FIR] Don't check Java annotations for cycles
^KT-64083 fixed
2023-12-07 08:56:56 +00:00
Nikita Bobko 0d67ae7b23 [TEST] Add regression test for KT-59805 ACTUAL_MISSING for constructor 2023-12-06 18:35:39 +00:00
Tomas Husak d7eb67a436 [FIR] KT-59368 context receiver subtyping checker 2023-12-06 17:34:05 +00:00
Ivan Kochurkin 3d77d09260 [FIR] Fix false positive errors on Throws::class, Throws()
^KT-63794 Fixed
2023-12-06 16:39:51 +00:00
Ivan Kochurkin 8dcd4efbc1 [FIR] Get rid of not needed set allocation in getSingleVisibleClassifier 2023-12-06 16:39:51 +00:00
Troels Bjerre Lund 4f77434ea5 [K/N] Remove LLVM coverage
The -Xcoverage feature has not worked and has been disabled for a while.
This fix removes it, and all of its uses.


Co-authored-by: Troels Lund <troels@google.com>


Merge-request: KOTLIN-MR-821
Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
2023-12-06 14:07:16 +00:00
Dmitrii Gridin e0c931f69d [LL FIR] rebind returnTarget for delegate accessors during psi2fir
It is safe to rebind returnTarget to the original declaration during
psi2fir as it doesn't affect the resolution. We already have the same
logic for regular functions/property accessors.
This change is crucial in the context of parallel implicit type
resolution because it affects CFG builder in a bad way in the case
of on-air resolution

^KT-56551
2023-12-06 12:59:55 +00:00
Dmitrii Gridin c59ea8bd2a [FIR] use delegate expression as source for FirWrappedDelegateExpressionBuilder
The previous implementation was not stable because `extractDelegateExpression`
has a source depending on extractDelegateExpression, and it led to
inconsistency in lazy and regular mode in the case of labeled expression
```kotlin
val a: String by l@ MyProperty()
```
In lazy mode the source is KtLabeledExpression, but in the regular one
is KtCallExpression

^KT-56551
2023-12-06 12:59:55 +00:00
Ivan Kylchik 1fcd277538 [FIR] Expand divisionByZero.kt test case
Added two new cases:
1. division where denominator is `val` property
with zero initializer;
2. division where denominator is `const val` property
with zero initializer.

Both such cases have different sets of diagnostics compared to K1.

#KT-59894 Fixed
2023-12-06 10:54:21 +00:00
Ivan Kylchik 5dbe81fd7f [FIR] Always expand a type before checking it in FirConstChecks
The issue appeared when we analyzed some typealias.
1. The typealias itself could be valid, but it could point
to an invalid type.
2. The typealias could point, for example, to an unsigned
type that must be handled in a special way

#KT-59894
2023-12-06 10:54:21 +00:00
Ilmir Usmanov 32e43998a0 IR: Restore method used by Anvil annotation processor
But make it hidden, so, the new method will be used instead
 #KT-62281
2023-12-06 09:52:07 +00:00
Kirill Rakhman 2391f00b75 [FIR2IR] Fix SAM conversion of adapted callable reference
#KT-63329 Fixed
2023-12-06 09:02:04 +00:00
Sergej Jaskiewicz c0c6667876 [FIR generator] Make Readme.md up-to-date 2023-12-05 20:30:22 +00:00
Sergej Jaskiewicz 8d1907e2f5 [FIR/IR generator] Introduce the common entry point for tree generators
This reduces code duplication.
2023-12-05 20:30:22 +00:00
Sergej Jaskiewicz 858343695c [FIR generator] Remove unused constant 2023-12-05 20:30:22 +00:00
Sergej Jaskiewicz 19ff050eae [FIR/IR generator] Move usedTypes to AbstractElement, rename it 2023-12-05 20:30:22 +00:00
Sergej Jaskiewicz e4078d163b [IR generator] Move each visitor printer into its own file 2023-12-05 20:30:22 +00:00
Sergej Jaskiewicz 8c75526130 [FIR generator] Move each visitor printer into its own file 2023-12-05 20:30:22 +00:00
Sergej Jaskiewicz 0c0f7f9899 [FIR/IR generator] Rename files with printers: use printer class's names 2023-12-05 20:30:22 +00:00
Mikhail Glukhikh 06ce57ea56 K2: report MISSING_DEPENDENCY_CLASS for lambda parameters if needed
#KT-62525 Fixed
2023-12-05 18:16:52 +00:00
Mikhail Glukhikh c03830556f [tests] Don't run Android codegen tests with IGNORE_BACKEND: ANY 2023-12-05 18:15:53 +00:00
Mikhail Glukhikh 4b649cbbe9 [tests] Drop a BI codegen test for should-be-red issue KT-63648 2023-12-05 18:15:53 +00:00
Mikhail Glukhikh 254bcdc80a [tests] Change builder inference tests in accordance with KT-53749 changes 2023-12-05 18:15:53 +00:00
Stanislav Ruban 7515efc52c [tests] Change builder inference tests in accordance with new K2 BI diagnostics
Related to KT-59369, KT-59390
2023-12-05 18:15:53 +00:00
Stanislav Ruban da0c3090a9 [tests] Regenerate test configurations 2023-12-05 18:15:53 +00:00
Stanislav Ruban c0bf67af22 [tests] Add test data for KT-63841 2023-12-05 18:15:52 +00:00
Stanislav Ruban 4f38d77fae [tests] Add test data for KT-63840 2023-12-05 18:15:52 +00:00
Stanislav Ruban 2bcaa3eb8f [tests] Add test data for KT-63733 2023-12-05 18:15:52 +00:00
Stanislav Ruban a836e94619 [tests] Add test data for KT-63648 2023-12-05 18:15:52 +00:00