Commit Graph

104038 Commits

Author SHA1 Message Date
Brian Norman 7db551c452 [FIR] Property accessors are not part of class initialization
When checking for class val property reassignment diagnostic, property
initializers should be treated as part of the class initialization.
However, property accessors should not. Previously, only the property
itself was checked for both of these situations and resulted in not
reporting diagnostic within property accessors.

#KT-59744 Fixed
2023-08-22 13:28:36 +00:00
Dmitrii Gridin e68cf38e99 [LL FIR] FirDeclarationForCompiledElementSearcher: avoid providers search for member declarations
This should improve performance and increase stability

^KT-61331
^KT-61014
2023-08-22 12:19:14 +00:00
Roman Efremov 1cf1a84594 [FE] Add TODO for safer check of memberExpectForActual writing
^KT-60668
^KT-60936
^KT-61361
2023-08-22 12:14:43 +00:00
Roman Efremov def4388c19 [FE, IR] Check annotations on expect and actual enum entries
^KT-60668
^KT-60936
2023-08-22 12:14:43 +00:00
Roman Efremov b57940a59b [FE1.0] Optimize search of expect class member in annotation checker
In the following scenario, when we search corresponding expect member
for actual `A.B`, we can skip checking compatibility of `B` scope.
```
class A {
  class B {
    fun foo() {}
  }
}
actual typealias AImpl = A
```

This is because:

1. Annotation checker runs no matter if found expect class is compatible
or not.
2. Class always has at most one corresponding `expect` class (unlike for
functions, which may have several overrides), so we are sure that we
found the right member.

^KT-60668
^KT-60936
2023-08-22 12:14:43 +00:00
Roman Efremov f1ea6545eb [IR] Fix incorrect position of reporting with fake overrides inside actual
^KT-60668
^KT-60936
2023-08-22 12:14:42 +00:00
Roman Efremov 58a30d524c [IR] Fix positioning of actual annotations diagnostic when reported on value
`parentsWithSelf` returns empty sequence if receiver is not a
`IrDeclarationParent`.

^KT-60668
^KT-60936
2023-08-22 12:14:42 +00:00
Roman Efremov ab1c0e3c48 [FE] Check annotations on actual class members including fake overrides
^KT-60668
^KT-60936
2023-08-22 12:14:42 +00:00
Roman Efremov d614f06259 [FE 1.0] Refactor: extract logic of matching actual against potential expects
Will be needed in subsequent commits for the annotation checker.
`findExpectForActual` is not suitable for the checker because
`findExpectForActual` searches expect class with same `ClassId` for
actual class containing current member (see method
`findClassifiersFromModule`), which is:
1. Unnecessary, since we already have expect class in annotation checker
2. Incorrect when class actualized via typealias and `ClassId` is
   different.

So, it is needed to extract logic of searching potential expects
for actual member and already known expect class.

^KT-60668
^KT-60936
2023-08-22 12:14:42 +00:00
Roman Efremov 8aa3ccd342 [FIR] Store matched actual class members inside FIR attribute
Currently, there is only attribute `ExpectForActualAttributeKey`
where mapping is stored only for source declarations with `actual`
modifier. But we need mapping of all class members, including classes
which were actualized via `actual typealias` or fake override members.
This data will be needed for the annotation checker in subsequent
commits.

^KT-60668
^KT-60936
2023-08-22 12:14:42 +00:00
Roman Efremov 2f00ed3ed7 [FE] Refactor: reorganize methods in AbstractExpectActualAnnotationMatchChecker
Separate callable and class checks to prepare for checking
class scopes. Extract common checks to separate methods.

Also, it is found that in IR checker annotations on type parameters also checked,
because they stored in `matchedExpectToActual`. But it is expected that
only classes and callables are checked. This started to fail because of
added input parameter type checks inside `areAnnotationsCompatible`.
That's why `expectSymbol is IrTypeParameterSymbol` early-return is added.

^KT-60668
^KT-60936
2023-08-22 12:14:42 +00:00
Mikhail Glukhikh 8cbefcc26f K2: add test to ensure #KT-55981 Obsolete 2023-08-22 11:40:26 +00:00
Mikhail Glukhikh 27afee8683 K2: generate bounds for inner-class based raw types properly
#KT-58579 Fixed
2023-08-22 11:40:26 +00:00
Mikhail Glukhikh 4e2067a163 K2: reproduce KT-58579 2023-08-22 11:40:25 +00:00
Mikhail Glukhikh 2ff075c961 FIR2IR: use ELVIS origin only on wrapping blocks #KT-60250 Fixed 2023-08-22 11:20:19 +00:00
Mikhail Glukhikh b06188180e FIR2IR: don't generate 'none' type arguments for Java field references
#KT-60254 Fixed
2023-08-22 11:20:19 +00:00
Mikhail Glukhikh 9846ec23df Raw FIR: generate 'return setValue' instead of just 'setValue'
#KT-61045 Fixed
2023-08-22 11:20:19 +00:00
Mikhail Glukhikh 7d5e2f85cc FIR2IR: don't generate unnecessary 'return throw'
#KT-60245 Fixed
2023-08-22 11:20:19 +00:00
Vladimir Sukharev 90904e4f8a [Tests] Add missing diagnostics handler to irText tests
Merge-request: KT-MR-11721
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-08-22 10:44:41 +00:00
Nikita Bobko ccfbb5f77a [FE] Don't issue a deprecation warning for open val deferred init when the property is unconditionally effectively final
^KT-61228 Fixed
Review: https://jetbrains.team/p/kt/reviews/11694/timeline
2023-08-22 10:15:22 +00:00
Nikolay Lunyak c33f1cda69 [FIR] Report MISSING_CONSTRUCTOR_KEYWORD
^KT-59407 Fixed
2023-08-22 09:13:16 +00:00
Nikolay Lunyak f238ffa4bf [FIR] Make FirErrorConstructor a FirDiagnosticHolder 2023-08-22 09:13:16 +00:00
Roman Efremov 673b4b4d52 [FE] Add OptIn annotation to whitelist of annotation checker
It's valid to have `@OptIn` only on `expect` declaration.

^KT-61373
2023-08-22 09:02:20 +00:00
Pavel Kunyavskiy 8bcd1f4efa [FIR/Native] Move fir-related code from backend.native module to new one
^KT-61249
2023-08-22 08:56:16 +00:00
Alexander Udalov fdab636a1b Tests: add missing language version in a Java modules test
The main function in this test class to compile a bunch of sources is
`module`, which was changed to test different language versions in
4e706ba93e. But this test uses `compileLibrary` directly, so we need to
pass LV manually.

 #KT-60797
2023-08-22 08:34:18 +00:00
Dmitrii Krasnov ade88e2b0f Fixed konan.data.dir with caches
Removed TODOs after updating to kotlin bootstrap version with konan.data.dir gradle property changes

Fixed warning of incorrect passing -Xkonan-data-dir arg in konanc from KGP and fixed setting konan-data-dir in SetupConfiguration#setupCommonOptionsForCaches

#KT-60660 Fixed

Merge-request: KT-MR-11299
Merged-by: Dmitrii Krasnov <Dmitrii.Krasnov@jetbrains.com>
2023-08-22 07:56:26 +00:00
Yahor Berdnikau e8905ea849 [Gradle] Fix loosing compiler plugin options with the same plugin ID
The most common use case is to add one CompilerPluginOptions to another
while both may have options with the same plugin ID.

^KT-54160 Fixed
2023-08-22 07:53:18 +00:00
Nikolay Krasko df55283148 Revert "[Build] Fix usage of --scan parameter with test retry"
It looks like tests retry doesn't work sometimes.

This reverts commit ecd06ac47b.

KTI-1346 KTI-1339
2023-08-21 21:01:18 +00:00
Dmitrii Gridin 695f6f0062 [SLC] fix annotation retention mapping
^KT-61377 Fixed
2023-08-21 20:46:25 +00:00
Dmitrii Gridin 566232fd0d [SLC] add test for binary retention
^KT-61377
2023-08-21 20:46:25 +00:00
Dmitrii Gridin 51cc799204 [SLC] fix flaky test 2023-08-21 20:46:25 +00:00
Dmitrii Gridin 175ce94bb5 [LL FIR] StubBasedClassDeserialization: provide psi class there is possible
We can provide psi declaration for nested classes to avoid search
through providers and improve stability

^KTIJ-26670 Fixed
2023-08-21 20:42:44 +00:00
Dmitrii Gridin faac4ad229 [LL FIR] add cache restoring in some situations
In some caches, we assume that the resulting value must be not null if
we provide a context, so we can fix the cache inconsistency in this case.
This is error situations that shouldn't happen, but currently we have
problems with script dependencies (KT-61267), so such checks will help
us to distinguish some LL FIR problems from dependency problems.

^KT-61331 Fixed
^KTIJ-26670
2023-08-21 20:42:44 +00:00
Nikita Bobko ad90c86abe jvm-minimal-for-test: apply module-wise -opt-in=kotlin.ExperimentalMultiplatform
Motivation: Consistency. All other stdlib modules use this module-wise
`-opt-in`
2023-08-21 19:51:08 +00:00
Nikita Bobko 25c082f02b K1: Implement a checker that disallows to have different member scopes for expect open and its actual
^KT-22841 Fixed
Review: https://jetbrains.team/p/kt/reviews/11603/timeline

The commit also introduces `@AllowDifferentMembersInActual` annotation in
stdlib which allows to suppress the diagnostic
2023-08-21 19:51:08 +00:00
Alexander.Likhachev 797ca34a34 [BT] Use bootstrap classloader as a fallback instead of system classloader
Using system classloader may lead to unwanted leakage of classes from the application classpath (like Gradle's ones).
#KT-61206 Fixed
2023-08-21 18:09:49 +00:00
Alexander.Likhachev 4705f13b39 [BT] Add a test for KT-61206 2023-08-21 18:09:49 +00:00
Igor Chevdar 9917c477e8 [K/N][linker] Name temp obj file the same as output binary
#KT-61270 Fixed
2023-08-21 18:06:02 +00:00
Kirill Rakhman d0cc86f52c [Tests] Update test data after changes to FIR diagnostic messages 2023-08-21 16:28:48 +00:00
Kirill Rakhman de1c92a32f [FIR] Update diagnostic messages 2023-08-21 16:28:48 +00:00
Kirill Rakhman 6cd9b5ec98 [FIR] Add guidelines for diagnostic messages 2023-08-21 16:28:48 +00:00
Kirill Rakhman aacbcc9d49 [FIR] Verify diagnostic messages use single quotes correctly 2023-08-21 16:28:47 +00:00
Roman Golyshev b760046f93 KTIJ-26713 [AA] Clean-up KtFirReferenceShortener
- revert some accidental changes in
`findSmallestElementOfTypeContainingSelection` function (see 48433bf9)
- simplify `dropFakeRootPrefixIfPresent` by using `tail`, add a new
test-case to check that it works
- simplify `findClassifierElementsToShorten` by not passing lambdas and
calling a common functions instead
2023-08-21 16:22:22 +00:00
Roman Golyshev 24a13348c4 KTIJ-26713 [AA] Handle FirFunctionTypeParameter in KtFirReferenceShortener
^KTIJ-26713 Fixed
2023-08-21 16:22:22 +00:00
Nikita Bobko 830084a678 Revert "Force recompile all call-sites of ExpectedActualResolver.{findActualForExpected, findExpectedForActual}"
This reverts commit 529a1dd720.

This commit was needed to workaround broken incremental compilation in
JPS in Kotlin plugin. The incremental compilation bug is reported
KT-60759

As promised in 529a1dd720, after a few
days in `master` I revert it

Review: https://jetbrains.team/p/kt/reviews/11724/timeline
2023-08-21 15:11:33 +00:00
Svyatoslav Scherbina 04d01e381f Native: disable running cinterop in Gradle process when building K/N
Building Kotlin/Native itself involves running cinterop in the Gradle
daemon process to reduce build time.
But this optimization appears to be incorrect when reusing Gradle daemon
for subsequent builds.

This commit disables the optimization by default, keeping enabling it
possible using `kotlin.native.allowRunningCinteropInProcess=true`
project property.

For more details see ^KT-61300
2023-08-21 14:15:28 +00:00
Dmitrii Gridin 3d52ba3bca [psi] KtFile: add hasImportAlias with caching
We have hotspots in UAST due to aliases, so we can reduce the time
significantly by caching `hasImportAlias` property

^KTIJ-26688
2023-08-21 13:57:10 +00:00
Dmitriy Novozhilov efb96e31fb [FIR] Fix implementation of primaryConstructorSymbol utility
Originally it used list of declarations, which is incorrect, because
  some constructors may be contributed by compiler plugin. And those
  constructors will be contained only in scope
2023-08-21 13:51:12 +00:00
Ilya Gorbunov 93b0a90172 Add missing SinceKotlin for new JS annotations, KT-6168 2023-08-21 12:49:21 +00:00
Kirill Rakhman fa77e3952d [FIR] Bring equivalent call behavior closer to K1
#KT-61159 Fixed
2023-08-21 12:11:58 +00:00