Commit Graph

102304 Commits

Author SHA1 Message Date
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
Yahor Berdnikau 36f748cbcc [Gradle] Fix Jvm Toolchain Android tests are not running on CI
JUnit5 combines tags and then applies to this combined list filters from
 the test task. If this list contains any excluded tag - test will be
 ignored.

^KT-59587 In Progress
2023-06-30 14:18:05 +00:00
Yahor Berdnikau 05ce873d2a [Gradle] Fix Android tests for Jvm Toolchain
^KT-59587 In Progress
2023-06-30 14:18:05 +00:00
Sergey Bogolepov d433d1eb3f KT-58862: Remove cinterop -mode option
metadata cinterop libraries perform pretty well for years,
so we can drop this flag.
2023-06-30 14:16:01 +00:00
Pavel Kargashinsky 807e7f1c28 [MPP][Tests] Bump AndroidAndJavaConsumeMppLibIT tests Gradle version to 7.6.
Tests will be failed if AGP >=7.1.0 or Gradle >= 8.0
See KT-57351 for details
2023-06-30 14:15:40 +00:00
Pavel Kargashinsky 816efc2def [MPP][Tests] Use max supported Gradle version for MPP old-dsl tests 2023-06-30 14:15:39 +00:00
Aleksei.Glushko 5618ee84f8 [K/N] try to reimplement safe points with a load-branch-call 2023-06-30 14:12:17 +00:00
Ilya Kirillov 5b4916a808 Introduce StandardNames.IMPLICIT_LAMBDA_PARAMETER_NAME
and use it instead of hardcoded constant
2023-06-30 13:43:31 +00:00
Ilya Kirillov 0a1f27e43a [LC] remove duplicating checkIsMangled function 2023-06-30 13:43:30 +00:00
Ilya Kirillov c4e8a6dee9 [SLC] implement isMangled for symbol light method
`isMangled` is needed for implementing rename refactoring

^KTIJ-25903
2023-06-30 13:43:30 +00:00
Ilya Kirillov 8b0eb0488f [Analysis API] add method for implicit companion object reference detection
Add a new method `isImplicitReferenceToCompanion` to determine
if the given reference is an implicit reference to a companion object.

The method is needed for the rename refactoring in IJ.

^KTIJ-25863
2023-06-30 13:43:30 +00:00
Alexander Udalov f5bbf2b4fe Reflection: create synthetic classes for Java lambdas
... as well as $SwitchMap and other synthetic classes generated by javac
or other JVM language compilers or runtimes.

Note that for Kotlin, all synthetic classes were already handled by the
subsequent check for `KotlinClassHeader.Kind.SYNTHETIC_CLASS`, but after
this change we won't call `ReflectKotlinClass.create` for those, which
is a minor optimization.

 #KT-41373 Fixed
2023-06-30 13:11:41 +00:00
Alexander Udalov 5dc882abf5 Reflection: create synthetic classes instead of throwing UOE
... for Kotlin-generated classes which do not correspond to a "class"
from the Kotlin language's point of view. For example, Kotlin lambdas,
file facade classes, multifile class facade/part classes, WhenMappings,
DefaultImpls. They can be distinguished from normal classes by the value
of `KotlinClassHeader.Kind` (which is the same as `Metadata.kind`).

Another theoretical option would be to throw exception at the point
where the `::class` expression is used, if the expression's type on the
left-hand side is a synthetic class. But we can't really do that since
it'll affect performance of most `<expression>::class` expressions.

So, construct a fake synthetic class instead, without any members except
equals/hashCode/toString, and without any non-trivial modifiers. It kind
of contradicts the general idea that kotlin-reflect presents anything
exactly the same as the compiler sees it, but arguably it's worth it to
avoid unexpected exceptions like in KT-41373.

In the newly added test, Java lambda check is muted but it should work
exactly the same as for Kotlin lambdas and other synthetic classes. It's
fixed in a subsequent commit.

 #KT-41373 In Progress
2023-06-30 13:11:41 +00:00
Alexander Udalov d833b732c9 Reflection: support Java anonymous/local classes
Local classes and anonymous objects are normal classes and
kotlin-reflect can load all declarations and modifiers from them, and
support calling members, exactly in the same way as it does for normal
non-local classes.

 #KT-41373 In Progress
2023-06-30 13:11:41 +00:00
Alexander Udalov 1e031d9fb8 Reflection: add test on introspection of local classes
kotlin-reflect works correctly already for Kotlin-generated local
classes and anonymous objects, but not for Java ones. This is fixed in a
subsequent commit.

 #KT-41373 In Progress
2023-06-30 13:11:41 +00:00
Sergej Jaskiewicz 9fcdc10019 [IR] Reorder parameters in IrFactory#createValueParameter
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-30 12:41:02 +00:00
Kirill Rakhman 2cc588d6d8 [RAW FIR] Rename raw FIR builder types for clarity 2023-06-30 12:05:43 +00:00
Ilya Kirillov 26e9e9de11 [LL FIR] add regression tests for KTIJ-23090
^KTIJ-23090 obsolete
2023-06-30 11:13:47 +00:00
Ilya Kirillov 048ecdf981 [Analysis API] add regression tests for KTIJ-24163
^KTIJ-24114 obsolete
2023-06-30 11:13:46 +00:00
Sergej Jaskiewicz 3f6420c5b9 [IR] Move IrFactory#createExpressionBody overloads to extension methods
This is to prepare for IrFactory auto-generation (KT-59308).
2023-06-30 11:06:09 +00:00
Nataliya.Valtman ea8b482f4f Don't get BuildScanExtension when buildScan report is disabled
#KT-59589: Fixed
2023-06-30 09:59:09 +00:00
ksenia.sergeeva 5e7e1e6c92 add gradle integration tests for explicit api mode in android KT-59117 2023-06-30 09:52:17 +00:00