Commit Graph

103075 Commits

Author SHA1 Message Date
aleksandrina-streltsova 57cbab7d8e [AA] Shortener: allow import if requested import kind has high priority 2023-07-03 15:08:05 +00:00
aleksandrina-streltsova a96e2f37e7 [Analysis API] Shortener: don't add import if it affects usages
^KTIJ-24096 Fixed
2023-07-03 15:08:04 +00:00
aleksandrina-streltsova 338c2433ac [Analysis API] Add API for expect/actual declaration detection 2023-07-03 15:08:04 +00:00
aleksandrina-streltsova da5f33d762 [Analysis API] Do not shorten qualifiers outside the selection range
^KTIJ-25116 Fixed
2023-07-03 15:08:04 +00:00
aleksandrina-streltsova ed7a3299f0 [Analysis API] Shorten qualifier of unresolved reference
^KTIJ-25115
2023-07-03 15:08:03 +00:00
Sergey Bogolepov 2d945b7226 [K/N] Disable KT-59167 test on watchOS 2023-07-03 14:45:21 +00:00
Ilya Goncharov 0bc19e70b6 [JS] Update npm dependencies in integration tests 2023-07-03 14:44:34 +00:00
Artem Kobzar 9ad5910de9 [K/JS] Remove isObject check from runtime ^KT-57926 Fixed 2023-07-03 13:19:43 +00:00
Sebastian Sellmair 23174add97 [Gradle] IdeBinaryDependencyResolver: Demote unresolved dependency logging to 'info'
The unresolved dependency built below will be reported by the
IDE as 'UnresolvedDependencySyncIssue'

KT-59844
2023-07-03 13:04:24 +00:00
vladislav.grechko 195ca10394 [FIR] Report error on non-public API access in @PublishedApi inline fun
^KT-59695: Fixed
2023-07-03 12:24:16 +00:00
Ilya Kirillov 36c8987df2 [FIR] fix exception on primary constructor parameter without a type
^KTIJ-25869 fixed
2023-07-03 11:40:18 +00:00
vladislav.grechko c6bd981fad [FIR] Fix order of arguments passed to inline function diagnostics
Accessibility-related diagnostics for inline function have the inline
function symbol as a first argument, and the forbidden callee as a
second one.

^KT-59673: Fixed
2023-07-03 11:39:57 +00:00
Dmitriy Novozhilov c8190707b3 [CODEOWNERS] Change owner of psi2ir from Compiler Core to JVM team 2023-07-03 11:29:20 +00:00
Vladimir Dolzhenko 4a7aea0dc6 Change the order of final properties initialization and ctor
To avoid case with NPE due to race-condition on publishing
non-fully initialized object in ctor via
`TypeRefinementSupport.Enabled(this)`

#KT-59852

Merge-request: KT-MR-10917
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-07-03 10:51:53 +00:00
Kirill Rakhman c7ae3c75db [FIR] Don't require delegated constructor calls for expect constructors
#KT-59640 Fixed
2023-07-03 10:17:22 +00:00
Kirill Rakhman 028921ade1 [FIR] Implement checker for value parameter default value type mismatch
#KT-58901 Fixed
2023-07-03 10:11:36 +00:00
Kirill Rakhman cfc824f9f2 [FIR] Set vararg modifier on data class copy method parameters
This only happens in red code, but it prevents unhelpful initializer
type mismatch errors.
2023-07-03 10:11:36 +00:00
Kirill Rakhman dcb200d6d3 [FIR LT] Optimize LighterASTNode.getChildNodeByType
Instead of creating a list first, return the first matching element of
the array.
2023-07-03 10:11:36 +00:00
Denis.Zharkov 8519053527 K2: Get rid of errorsToIgnore parameter during error reporting
The reason is that it's potentially might lead to some errors
are actually ignored leading to false-negatively green code,
while on the other hand we don't have any evidences (like tests)
that not-having the parameter lead to at least some redundant diagnostics.
2023-07-03 10:06:45 +00:00
Denis.Zharkov ffcb4cd1cb Add kdoc for LanguageFeature.AllowEmptyIntersectionsInResultTypeResolver
^KT-51221 Related
2023-07-03 10:06:45 +00:00
Alexander Kuznetsov c63a9582aa [debugger] IrFile for KtBlockCodeFragment should have a module
A module created for expression evaluation contains `fragment.kt`,
the file that contains necessary code for the expression
to be successfully evaluated (including the expression itself).
However, the IrFileImpl created for the fragment doesn't refer
to the module, leaving its lateinit `module` property uninitialized.
So, simply put, a parent has a child, but that child
doesn't have the parent. And that may lead to various errors.

Compose has a psi2ir lowering that transforms Composable declarations,
and for that it deep-copies all the declarations
(see `androidx.compose.compiler.plugins.kotlin.lower.
ComposerParamTransformer#lower`).
During the copying, it eventually tries to access that uninitialized
`module` property (`org.jetbrains.kotlin.ir.util.
DeepCopyIrTreeWithSymbols.visitFile`),
which predictably ends up with an exception.
The exception propagates down the stack, interrupting further
Compose lowerings, but eventually it gets swallowed at
`com.android.tools.compose.ComposePluginIrGenerationExtension#generate`.
So, fragment compilation continues and brings forth more complicated
errors on later stages, in particular during the codegen,
like in the IDEA-320738, when some declarations don't have
their lateinit `parent`s initialized.
This one example in the issue strikes during expect declarations
lowering at `org.jetbrains.kotlin.backend.common.lower.
ExpectDeclarationRemover.tryCopyDefaultArguments`.

The problem arisen in the issue could be solved on the Compose side,
but there's no telling what else can get broken because of
this module-file inconsistency.

Fixes IDEA-320738

Merge-request: KT-MR-10914
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2023-07-03 09:55:29 +00:00
Ilya Kirillov 5675c19f3b [Java Resolution, LL FIR] fix PsiInvalidElementAccessException from JavaClassifierTypeImpl.substitutor
The cached `PsiSubstitutor` might be invalidated, in this case we should recompute the value

Also make the `JavaClassifierTypeImpl` to be thread safe

^KT-59667 fixed
2023-07-03 07:55:36 +00:00
Anna Kozlova 600b5ec6e5 [FIR] preserve real source for property accessors
^ KT-59705
If property is delegated, it can't have property accessors with non-default impl,
but it can contain property accessors declarations
with non-default visibility, annotations, etc.
Seems, it's more logical to preserve them as fake sources
than use property itself
2023-07-03 08:46:40 +02:00
Denis.Zharkov 3279313f2c K2: Fix priority for implicit receiver + extensionInvoke
See K1 counterpart at org.jetbrains.kotlin.resolve.calls.tower.TowerResolver.Task.processImplicitReceiver

^KT-58943 Fixed
^KT-59541 Fixed
2023-07-01 16:29:06 +00:00
Denis.Zharkov 1f120ecd20 K2: Adjust invoke priorities with K1
- At first, get rid of a kind of interceptTowerGroup callback and use
explicit towerGroup construction instead
- Get rid of INVOKE_RECEIVER (not sure exactly why it was needed)
- Make comparison consistent with tower-levels priority of K2
(see the comments in the compareTo code)

^KT-37375 Fixed
^KT-58940 Open
2023-07-01 16:29:05 +00:00
Denis.Zharkov 04dd209f8d K2: Inline constant parentGroupForInvokeCandidates parameters 2023-07-01 16:29:04 +00:00
Denis.Zharkov 38592d1423 K2: Minor. Apply "Convert to 'data object'" to TowerGroupKind inheritors 2023-07-01 16:29:04 +00:00
Denis.Zharkov acb1859154 K2: Fix current behavior for KT-37375 and KT-58943 2023-07-01 16:29:04 +00:00
Denis.Zharkov f37dc27974 K2: Fix incorrect UNRESOLVED_REFERENCE after aliased import in other file
The problem is actually caused by 60f09f6512
It happened because we've been caching package scope using FqName key,
so once one file contains aliased import it would work like other file
contains it, too.

So, the fix is adding excludedNames to the key, too.

^KT-59789 Fixed
2023-07-01 16:27:23 +00:00
Denis.Zharkov b18b2abe05 K2: Add test describing the state for KT-59789 2023-07-01 16:27:23 +00:00
Anastasia.Nekrasova 62d8d04b51 [Test] Add a test covering missed error for virtual inline vals in enum classes
Addition to inline functions that are already present in tests.

^KT-34372
2023-07-01 15:10:05 +00:00
Sebastian Sellmair 4e85434536 [Gradle] Implement CompilationAssociator.default, ...
... to allow extending the default behaviour for ExternalTargetApi consumers

^KT-59562 Verification Pending
2023-07-01 06:58:16 +00:00
Artem Kobzar 966a342bf1 [K/JS] Migrate invalidation tests to ES modules 2023-06-30 16:13:35 +00:00
Abduqodiri Qurbonzoda 209c916a7e OptIn ExperimentalNativeApi 2023-06-30 15:27:09 +00:00
Abduqodiri Qurbonzoda aae8a687a4 [K/N] Internalize Retain and RetainForTarget annotations #KT-57710
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Abduqodiri Qurbonzoda f665388704 Advance ExperimentalNativeApi opt-in requirement level to ERROR #KT-57838
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Abduqodiri Qurbonzoda ba6ee484b8 Advance NativeRuntimeApi opt-in requirement level to ERROR #KT-57720
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Abduqodiri Qurbonzoda 00abbc5cfe Advance ObsoleteNativeApi opt-in requirement level to ERROR #KT-57088
As a part of efforts to stabilize Native stdlib.
2023-06-30 15:27:08 +00:00
Yan Zhulanow d04ed56a4d [LL API] Add tests for FIR tree guards
^KT-59297 Fixed
2023-06-30 14:26:43 +00:00
Yan Zhulanow 91c3ebac27 [LL API] Replace whole-session invalidation with granular FIR guards
^KT-59297 Fixed

'ProcessCancelledException's are commonly thrown during code analysis,
yet not every place is ready for them. As a FIR tree is a mutable data
structure with no transaction support, sporadic halts during its
mutation might easily leave it in an inconsistent state.

Before this change, whole module sessions (with all dependents) were
invalidated if an exception occurred during their analysis. Not only it
was very ineffective, it also resulted into a concurrency problem.

'ProcessCancelledException's are thrown when an underlying progress
indicator is invalidated. As analysis in each thread might have its own
progress indicator, invalidation in one thread should not stop
analysis in others. However, it is impossible in the current state,
as all threads share the same FIR tree structure.

The change introduces 'FIR guards' – a set of instructions defining
preservation and restoration rules for individual state items. As each
resolution phase is supposed to modify only a (sort of) known subset
of tree elements, restoration of potentially changed state on a failure
effectively returns the tree consistency.

Note that guards are not defined for certain phase transformers. The
reason is that the transformers already update the tree content safely.
E.g., the type reference is updated once it is resolved, and already
resolved type references are either resolved the same way again, or
just skipped on consequent phase runs.
2023-06-30 14:26:43 +00:00
Yan Zhulanow d386dd1f7b [LL API] Minor, prettify naming in 'LLFirBodyLazyResolver' 2023-06-30 14:26:43 +00:00
Yan Zhulanow 2aaf589ef2 [LL API] Minor, simplify call sites in 'transformAnnotations()' 2023-06-30 14:26:43 +00:00
Yan Zhulanow c7c49fd267 [LL API] Minor, clean up 'handleExceptionFromResolve()' 2023-06-30 14:26:42 +00:00
Yan Zhulanow 89797815a4 [FE] Implement safe publishing in ARGUMENTS_OF_ANNOTATIONS 2023-06-30 14:26:42 +00:00
Yan Zhulanow 90977f6a8c [FE] Extract special access patching logic in ARGUMENTS_OF_ANNOTATIONS 2023-06-30 14:26:42 +00:00
Yahor Berdnikau 89f7053437 [Gradle] Add comment why nagFreeCompilerArgsModification message is not shown
Gradle 8.0 suppresses such messages produced by `kotlin-dsl` plugin

^KT-59587 Fixed
2023-06-30 14:18:06 +00:00
Yahor Berdnikau 447c849b29 [Gradle] Fix jvm target validation test on Gradle 8
^KT-59587 In Progress
2023-06-30 14:18:06 +00:00
Yahor Berdnikau 6a80cd596a [Gradle] Fix kapt jvm target validation test on Gradle 8
^KT-59587 In Progress
2023-06-30 14:18:06 +00:00
Yahor Berdnikau 9453deb840 [Gradle] Update jvm validation test tags
Annotation each test separately, so each test should run on CI.

^KT-59587 In Progress
2023-06-30 14:18:05 +00:00
Yahor Berdnikau 6cf35c74af [Gradle] Update toolchain tests to run on Gradle 8+
^KT-59587 In Progress
2023-06-30 14:18:05 +00:00