Commit Graph

44677 Commits

Author SHA1 Message Date
Mikhail Glukhikh 336ea28735 Drop setting progressive mode in cli / cli-base (related to KT-59171)
This commit prevents language version increase due to bootstrapping
problems. Compiler version X attempts to build the project with the
current version X+1 -> warning about progressive mode cannot be enabled ->
error due to -Werror -> build failure.
2023-07-26 18:19:58 +00:00
Leonid Startsev 648c1f4599 Support instantiation of annotations with type parameters
By ignoring type parameters. Since type parameters in annotations are a
very limited feature, their sole use is to be able to specify them as
KClass argument: annotation class Foo<T: Any>(val bar: KClass<T>).
Since we can encounter type param only as a KClass type argument (and
never as a property type), simple approach of ignoring them works fine.
In that case, since we simply copy property types to synthetic
implementation class, its properties in IR start look like this:
annotation class FooImpl(override val bar: KClass<T of Foo>). This IR
seems to be not completely correct, since FooImpl.bar type contains T of
Foo param, which is out of its scope. However, so far I didn't
encounter any problems with this during testing and after MR discussion
this approach has been considered possible.

#KT-59558 Fixed
#KT-59036 Fixed
2023-07-26 17:16:13 +00:00
Nikita Bobko 8c795462e1 Effective modality cleanup. Drop unnecessary @Suppress and final
They were needed as a temporary migration in scope of KT-58587

Now the bootstrap and IDE include KT-58587 patch, so @Suppress and
`final` are no longer needed
2023-07-26 16:48:25 +00:00
Yan Zhulanow fefa72fa29 [BE] Use more generic 'FacadeClassSource' in 'parentClassId'
In the IDE's evaluator, the container source for stub-based FIR
declarations is a different implementation of 'FacadeClassSource'.
2023-07-26 16:03:44 +00:00
Ilya Kirillov e3d2bccb33 [LL FIR] fix user code leak from exceptions in :analysis:low-level-api-fir
Also, add more info to some exceptions
2023-07-26 14:29:20 +00:00
Ilya Goncharov 1f9af4b452 [Gradle, JS] Fix cli tests for ir
KT-60495
2023-07-26 12:51:37 +00:00
Pavel Kunyavskiy 38ef5be217 [K/N] Don't store private signatures in symbol table
Refactoring in 4986cb14 introduced an unintentional behavior change:
private symbols are now findable in symbol table with lookup by
signature.

Unfortunately, this is not correct - private symbol signature might not
be unique (or at least was sometimes not unique in older compiler
versions), which leads to crashes on deserializing corresponding klib.

This commit restores old behavior.

^KT-60616
2023-07-26 12:03:26 +00:00
Ilya Kirillov cc27bfd39a [Analysis API] fix "scope for class ConeClassLikeTypeImpl not found exception" when stdlib is missing
^KT-60641 fixed
2023-07-26 10:53:56 +00:00
Ilya Chernikov 3dc94f3d31 Scripting: fix descriptor extraction, restore main-kts testing
Temporary solution for K1 - see comments in the code
it seems that a scenario reproduced in the MainKtsTest.testKt48812
wasn't covered with analogous changes before.
And it wasn't detected while main-kts tests weren't a part of the
K1 scripting tests.
The test is fixed now, and testing of main-kts is restored.
2023-07-26 08:49:27 +00:00
Ilya Chernikov 776cdbcd3f minor: small cleanup in K2 scripting support code 2023-07-26 08:49:27 +00:00
Ilya Chernikov 895a811b47 K2 Scripting: fix capturing from the imported scripts 2023-07-26 08:49:27 +00:00
Ilya Chernikov 1d88c307ea K2 Scripting: fix locality of script declarations
the script declarations are considered public, at least because they
can be reused from another script then used with the `importedScripts`
configuration property. It also improves the compatibility with K1
scripting.
2023-07-26 08:49:27 +00:00
Ilya Chernikov 020a590df7 K2 Scripting: fix order of arguments processing
and base class handling:
Since in K2 we do not distinguish between script arguments taken from
the base class and provided properties, we need this extra functionality
to preserve the argument order of K1 scripts.
This is a temporary measure, since we're going to deprecate base class
usage at some point (KT-60449), so the relevant constructor arguments
should disappear too.
2023-07-26 08:49:27 +00:00
Ilya Chernikov 96bde033e1 K2 Scripting: add support for imported scripts 2023-07-26 08:49:26 +00:00
Ilya Chernikov d24fc3b581 K2 Scripting: add support for result field 2023-07-26 08:49:26 +00:00
Ilya Chernikov 6c7751b0af K2 Scripting: add support for script implicit receivers 2023-07-26 08:49:26 +00:00
Ilya Chernikov 266a223460 Update scripting plugin autoload logic for K2 2023-07-26 08:49:26 +00:00
Mikhail Glukhikh 5836a8aa0b K2: add more tests/fix augmented assignment case around KT-59748 2023-07-26 06:09:15 +00:00
Mikhail Glukhikh f20e2dec31 K2: generate Unit conversion for indexed assignment at raw FIR stage
#KT-59748 Fixed
2023-07-26 06:09:15 +00:00
Mikhail Glukhikh 1832413a02 K2: reproduce KT-59748 2023-07-26 06:09:15 +00:00
Mikhail Glukhikh a428ab6ed6 K2: handle alias-based types nullability properly in ConeTypeContext
#KT-60154 Fixed
2023-07-26 06:02:42 +00:00
Nikita Bobko f4ba5aaf9a [FE 1.0] Prohibit implicit Java actualization in K1
^KT-58545 Fixed
Review: https://jetbrains.team/p/kt/reviews/10561

It's not yet supported in K2 KT-59213

Related tests:
- ApiTest.testStdlib
- RuntimePublicAPITest.kotlinStdlibRuntimeMerged
- KotlinProjectViewTestGenerated.test_Arrays (in Kotlin plugin)
2023-07-25 22:30:09 +02:00
Svyatoslav Kuzmich 384c700a85 [Wasm] Fix access to WebIDL dictionary members
Evaluate external interface companion objects as an empty JS object
instead of null due to null checks on interop boundary.

^KT-59082 Fixed
2023-07-25 15:27:22 +00:00
Pavel Kunyavskiy 9cbd55aa72 [K/N] Intrinsify enumEntries<T>
^KT-59711
2023-07-25 14:24:44 +00:00
Nikolay Lunyak 57908eba77 [FIR] Prevent replacing UNNECESSARY_SAFE_CALL with UNEXPECTED_SAFE_CALL
UNNECESSARY_SAFE_CALL is a warning,
UNEXPECTED_SAFE_CALL is an error, thus
it's a breaking change.

Also see KT-60695.

^KT-59860 Fixed


Merge-request: KT-MR-11210
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-07-25 13:16:37 +00:00
Arseniy Terekhov be9d2953b2 [FIR] Make own accept methods of FirTypeParameterRef inheritors
This change is necessary in order to make `FirElement` abstract class. To do it we need to remove all `accept` and `transform` methods from fir interfaces. So we have to make sure that all fir element implementations have their `accept` and `transform` implementations in their super classes. In particular this change makes 'accept' and 'transform' methods in `FirConstructedClassTypeParameterRef` and `FirConstructedClassTypeParameterRef` base classes.
2023-07-25 11:53:47 +00:00
Arseniy Terekhov 4d85cc8aa6 [FIR] Make FirImport an abstract class
This change is necessary in order to make `FirElement` abstract class. To do it we need to remove all `accept` and `transform` methods from fir interfaces. So we have to make sure that all fir element implementations have their `accept` and `transform` implementations in their super classes. In particular this change makes `FirImport` abstract class in order to preserve `accept` and `transform` methods after removing them from fir interfaces.
2023-07-25 11:53:47 +00:00
Kirill Rakhman 06d2befb72 [FIR] Implement DATA_CLASS_OVERRIDE_DEFAULT_VALUES diagnostic
#KT-59415 Fixed
2023-07-25 11:25:43 +00:00
Kirill Rakhman 53ff4584d4 [FIR] Implement DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE diagnostic
#KT-59409 Fixed
2023-07-25 11:25:43 +00:00
Dmitrii Gridin d93ffe0aec [FIR] add missing resolve for ConeFunctionExpectedError building
^KT-60638 Fixed
2023-07-25 10:55:41 +00:00
mvicsokolova ba7e6ff154 [K/N] Intrinsics for atomic get/set of volatile properties.
These intrinsics are equivalent to KMutableProperty0.get/set invocation and used internally to optimize allocation of a property reference.


Merge-request: KT-MR-11233
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-25 10:53:37 +00:00
Alexander Udalov 971b4e63e7 JVM: support enumEntries intrinsic for Java & old Kotlin enums
#KT-59710 Fixed
2023-07-25 09:55:43 +00:00
Alexander Udalov 874d1c514a JVM: support enumEntries intrinsic for Kotlin enums
Implementation is very similar to the `enumValues` intrinsic.

Java enums and old (pre-1.9) Kotlin enums will be supported in a
subsequent commit.

 #KT-59710
2023-07-25 09:55:43 +00:00
Pavel Kirpichenkov 9b82ff7a8d [LL] Don't filter out metadata declaration from stub symbol provider
Now the stub-based symbol provider is reused for common source sets,
which use metadata dependencies. Filtering should be done on scope
level, then declaration provider won't yield them in the first place.

KT-58769
2023-07-25 09:15:30 +00:00
Pavel Kirpichenkov 71b29f0cd7 [tests] Add a diagnostic test for function resolution in common module 2023-07-25 09:15:29 +00:00
Pavel Kirpichenkov b316aa7d1d [AA] stub-based library symbol providers for non-JVM platforms
Use existing stub-based JVM library symbol provider for .knm and
.kotlin_metadata files. The only real difference is the scope filtering
by file types

KT-58769
2023-07-25 09:15:29 +00:00
Kirill Rakhman 129b930bd7 [FIR] Implement NOT_SUPPORTED_INLINE_PARAMETER_IN_INLINE_PARAMETER_DEFAULT_VALUE diagnostic
#KT-59398 Fixed
2023-07-25 07:48:22 +00:00
Nikolay Lunyak ed493c99e3 [FIR] Unset EnhancedNullability on withNullability() calls
Note that `FlexibleNullability` doesn't
exist anymore: it was removed at
`65ea4e18`.

`preserveEnhancedNullability = true`
was needed because if we have an
`@EnhancedNullability DNN`, and we
substitute something into it, then
`withNullability` is called there becase
that's how DNNs work, not becase we want
to obtain some new type with a
different nullability.

This is backed by
the `compiler/testData/diagnostics/tests/j+k/integerNotNullable.kt` test
 where we first have
 `@EnhancedNullability T & Any`, then
 we substitute `{T -> kotlin/Int!}` and
 then inside
 `org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor#substituteOriginal`
 (this is a DNN-specific function) we
 call `withNullability(NOT_NULL)`,
 and expect the attribute to be preserved. Otherwise this test would
 fail with
 `OVERLOAD_RESOLUTION_AMBIGUITY` for
 `IntBox().put(1)`.

^KT-50221 Fixed


Merge-request: KT-MR-11272
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-07-25 07:03:04 +00:00
vladislav.grechko e5763a692f Substitute type arguments to return type of inlined function references
Such substitution is crucial on codegen stage if the return type is
reified (e.g. for `Array`)

^KT-59507: Fixed
^KT-59281: Fixed
2023-07-24 22:11:59 +00:00
Sergej Jaskiewicz f5a00c788a [klib] Disable ManglerChecker on K2
`ManglerChecker` is a class that verifies that for each IR declaration
(except some, see its `needsChecking` property) its mangled name
(computed from IR) is the same as the mangled name computed from its
frontend representation — `DeclarationDescriptor` on K1 or
`FirDeclaration` on K2.

The way it does it is as follows.

On K1, `ManglerChecker` looks if the declaration has a true,
non-IR-based descriptor, it if it does, then it checks it
(see ManglerChecker.Companion#hasDescriptor).

On K2, since we don’t have any descriptors, `ManglerChecker` looks if
the declaration’s metadata property is `null` (because the corresponding
`FirDeclaration` is stored there). If it’s not, it checks it
(see ManglerChecker.Companion#hasMetadata).

The issue is that those two conditions are not equivalent.

When the Compose compiler plugin transforms an IR function, it copies
its `metadata` property (as it should, because `metadata` can contain
anything, not necessarily the frontend representation), but doesn't set
the descriptor. Because of that, on K1 that transformed function is
skipped in `ManglerChecker`, and on K2 it’s not.

The correct usage would be to properly distinguish which declarations
come from the FE as is, and which are transformed/synthesized,
and skip the latter. But it is unclear how to implement this.

For now, the easiest way to fix this on K2 is to not run ManglerChecker
at all.

KT-60648
^KT-59448 Fixed
2023-07-24 19:29:17 +00:00
Igor Yakovlev e8e8a26cd1 [Wasm] Fixed invalid delegated property getters lowering
#Fixed KT-58941
2023-07-24 18:15:16 +00:00
Pavel Kunyavskiy 488d24296a [K/N]: Allow invocation of volatile intrinsics on inline function constant arguments.
Invocation of atomic intrinsics is only allowed on property references that are known at compile time. This commit makes it possible to also invoke intrinsics on a constant property reference getter passed as an argument.
See KT-58359

Co-authored-by: Pavel Kunyavskiy <Pavel.Kunyavskiy@jetbrains.com>

Merge-request: KT-MR-10413
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2023-07-24 17:45:16 +00:00
Sergej Jaskiewicz d77af3c43d [IR] Remove unnecessary ReplaceWith from deprecated methods in IrFactory
ReplaceWith doesn't do anything when deprecation level is HIDDEN.
2023-07-24 17:42:45 +00:00
Sergej Jaskiewicz 8aa0b6a562 [IR] Automatically generate IrFactory interface
^KT-59308 Fixed
2023-07-24 17:42:45 +00:00
Sergej Jaskiewicz c2a8d46867 [IR] Restore compatibility for IrFactory#createPropertyWithLateBinding
This is a follow-up to b4335c86c8.
2023-07-24 17:42:45 +00:00
Ivan Kylchik a56b462eb6 [IR] Reuse IR utils functions to find methods of Any in interpreter 2023-07-24 17:20:39 +00:00
Ivan Kylchik 1eca5d1a3b [IR] Rewrite how interpreter works with the Unit result
This way interpreter works in more correct way. Every expression
produces some result, and if we don't need it, the interpreter will
discard it.
2023-07-24 17:20:39 +00:00
Ivan Kylchik 6204119219 [IR] Simplify logic of constructing unsigned number in interpreter
This way it is a little less "hacky". We are looking only for "data"
property, and as long as this property is declared in constructor, we
can safely assume we will get the correct one even if it is
renamed.
2023-07-24 17:20:39 +00:00
Ivan Kylchik d795ce3582 [IR] Simplify logic of interpretCall
Drop excess call of `callStack.loadState(it)` when store state for
extension receiver. When we interpret lambda with extension receiver,
this receiver will be actually represented as a value parameter,
and it required some additional processing. Apparently, after all
interpreter's refactorings, this does not matter anymore and excess
call can be dropped.
2023-07-24 17:20:39 +00:00
Sergej Jaskiewicz b57b4e055e [klib] Move some duplicated code from subclasses to IdSignatureBuilder 2023-07-24 16:40:15 +00:00