Commit Graph

3923 Commits

Author SHA1 Message Date
Ilya Chernikov fecc5ba501 K2: do not try to resolve invoke on error receiver
If a potential receiver is resolved to an error type, we consider
any other type as a subtype of it and therefore may select
any candidate that we happen to find in a scope.
In particular, in the case of scripts, or code with a context receiver,
the receiver candidate resolved to a cycle was accepted as a receiver
to an invoke on a random class from stdlib.
The fix skips adding invoke resolve task in this case, allowing
the tower to find the correct candidate in another scope.

#KT-64241 fixed
#KT-65576 fixed
2024-03-19 15:38:35 +00:00
Ilya Chernikov d5ad41fa28 K2 Scripting: add failing test for #KT-64241 2024-03-19 15:38:35 +00:00
Ilya Chernikov 60e38d592c Tests, Scripting: extend custom def test infra with gradle-like def
to be able to test gradle-like DSL
2024-03-19 15:38:34 +00:00
Leonid Startsev dbb7ab1760 Add @Deprecated annotation to a synthetic $serializer class
in K2 so it matches K1 behavior.

Deprecation is required, so the declaration will not be visible to user in completion in the IDE.

#KT-65757 Fixed
2024-03-19 10:57:27 +00:00
Marco Pennekamp 53f2dfec41 [Kapt4] Update Kapt4 test data after AA Standalone fix for sealed inheritors
- The Standalone Analysis API now correctly calculates sealed inheritors
  in source modules. This causes Kapt4 to pick up on sealed subclasses
  in the `modifiers` test. The change is in line with the non-FIR test
  results in `modifiers.txt`.

^KT-66013
2024-03-18 21:14:36 +00:00
Leonid Startsev 7c8c65d291 Call a specified function in intrinsic if polymorphic serializer is provided for interface.
This prioritizes module contents over default polymorphic serializer.

See https://github.com/Kotlin/kotlinx.serialization/issues/2060 and https://github.com/Kotlin/kotlinx.serialization/pull/2565
2024-03-18 17:21:16 +00:00
Alexander Udalov e007153ae6 Parcelize: remove testData for old JVM backend
Old JVM backend implementation was removed in 163a052f98 along with
tests, but .asm.txt files were not removed.
2024-03-18 12:06:36 +00:00
Leonid Startsev 69ad68ca83 Make intrinsics more consistent with reflective serializer() lookup
Intrinsic should not look into use-site `@Serializable(with)` annotations.

#KT-64920 Fixed
2024-03-15 17:29:48 +00:00
Mikhail Glukhikh 8ac576614f Revert "Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551)"
This reverts commit 893e5cac
2024-03-15 11:33:10 +00:00
Christian Melchior 4464385fa9 Scripting: KT-62576 Remove irrelevant output from classpath debug information.
Merge-request: KT-MR-14868
Merged-by: Christian Melchior <christian.melchior@jetbrains.com>
2024-03-14 20:52:27 +00:00
Alexander Udalov 324d2e042a Tests: do not report backend diagnostics in diagnostic tests
There's a separate test data directory `testsWithJvmBackend` with a
runner that properly invokes the JVM backend and reports diagnostics
from it. All tests where JVM diagnostic presence/absence is important
were copied/moved there in this and previous commits.

The problem with the code removed in this commit is that it invoked some
parts of the _old JVM backend_ and old light classes, which is very far
from what users see in the production compiler at this point. This led
to real issues where we implemented incorrect behavior in K2 based on
the misleading diagnostic report from the K1 test.

The diagnostic in `triangleWithFlexibleTypeAndSubstitution4.kt` was
removed, but there's a copy of this test in `codegen/box/javaInterop`
which fails for K2 (KT-66529).

The diagnostic in `intersectionWithMappedSignature.kt` was removed and
that is OK because at this point CONFLICTING_JVM_DECLARATIONS there
seems like a bug in the old JVM backend.
2024-03-14 12:38:48 +00:00
Mads Ager b0bc017a16 [Parcelize] Add test for parcelize in multiplatform setting.
This tests that classes in common code can have code generated
for them in android compilations.
2024-03-14 06:52:19 +00:00
Mads Ager fa0d456850 [Parcelize] Allow parcelize to work on common code in multiplatform.
Since parcelize is Android specific, it should only be enabled for
Android compilation. In order to allow parcelize to generate code
for declarations in common code, we make checkers platform checkers
and we allow the registration of an additional annotations to
trigger parcelize processing.

That way, code such as:

```
package my.package

annotation class Parcelize

expect interface MyParcelable

@Parcelize
data class User(name: String): MyParcelable
```

Will work with an Android platform actual of the form:

```
actual typealias MyParcelable = android.os.Parcelable
```

And telling the plugin to trigger parcelize processing with the
additional annotation `my.package.Parcelize`.

Fixes https://issuetracker.google.com/315775835.
2024-03-14 06:52:19 +00:00
Sonya Valchuk b6d73fc6ac jvm-abi-gen: use asm flag to skip debug info 2024-03-13 21:31:19 +00:00
Sonya Valchuk 9518416bdb jvm-abi-gen: remove parts of the SMAP used only in stripped methods 2024-03-13 21:31:19 +00:00
Mikhail Glukhikh 893e5cac94 Temporary: mute PRE_RELEASE_CLASS in some tests (KT-66551) 2024-03-13 20:38:44 +00:00
Kirill Rakhman 8443daf78d [FIR] Remove FirNamedArgumentExpressions during completion
They are mostly necessary for argument mapping during resolution.
To support a couple checkers, we transform named args for varargs
into "fake" spread expressions.

Other than that, named arguments aren't needed for anything and often
lead to bugs where we forget to unwrap them for something, so it's
better to get rid of them.

#KT-66124
2024-03-13 17:05:48 +00:00
Kirill Rakhman 03fc0fd381 [FIR] Remove FirLambdaArgumentExpression
It's not really necessary if the information about if the lambda was a
trailing lambda can be directly saved in FirAnonymousFunctionExpression.

Removing the FIR node uncovered a couple of bugs
(UNINITIALIZED_ENUM_ENTRY, ERROR_IN_CONTRACT_DESCRIPTION) that were
caused by assuming that a lambda is always a trailing lambda.

#KT-66124
2024-03-13 17:05:48 +00:00
Ilya Chernikov 0fe793943d K2, REPL: Display a warning that LV 1.9 is used for REPL in K2
#KT-64384 fixed
2024-03-12 15:57:00 +00:00
Vladimir Sukharev aa1cce78c3 [FIR] Incorrect warnings about inline function impact
^KT-65959 Fixed
2024-03-12 10:26:23 +00:00
Dmitriy Novozhilov d352cc9d96 [Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
2024-03-12 06:43:58 +00:00
Alexander Udalov d5c2aa4c0c IR: rename and move deepCopyWithVariables
Rename it to `deepCopyWithoutPatchingParents`, move to
`org.jetbrains.kotlin.ir.util`, make it inline+reified, and extract the
common implementation with `deepCopyWithSymbols` into `deepCopyImpl`.
2024-03-11 11:49:10 +00:00
Alexander Udalov 1d38c01afc IR: remove some usages of deepCopyWithVariables
At this point, `deepCopyWithVariables` is the same as
`deepCopyWithSymbols` except that the former doesn't call
`patchDeclarationParents`, which most likely produces incorrect IR in
some call sites.
2024-03-11 11:49:10 +00:00
Ivan Kylchik c07781326b [K2] Remove performanceManager from CompilationContext 2024-03-08 15:58:33 +00:00
Brian Norman 6bf987e772 [AllOpen] Do not open members of non-class type classes
The logic of the AllOpen compiler plugin for opening classes and opening
declarations of classes does not match. This leads to declarations being
open when the containing class is not open. There is a warning reported,
for exactly this situation.

However, creating meta-annotations of AllOpen annotation is quite common
in certain ecosystems. In particular, Spring. This can lead to a warning
if the meta-annotation has properties.

Align the class kind check for members, so they are not opened if the
containing class cannot be opened.

^KT-63507 Fixed
2024-03-08 14:55:39 +00:00
Brian Norman bdaacb9427 [AllOpen] Test case to recreate open annotation member warning
The AllOpen compiler plugin opens all declarations of the annotated
class, regardless of class type. However, it only opens classes (not
interfaces, objects, enums, etc). This leads to a warning where members
of an annotation are open when annotated. Spring has many such
annotations, as it is common to create meta-annotations from the core
set of AllOpen supported annotations.

^KT-63507
2024-03-08 14:55:39 +00:00
Wojciech Litewka 943be239ee [IR] Simplify IrFileImpl and IrExternalPackageFragment
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Dmitrii Gridin d5cfea330b [LL FIR] support parameters resolution
Script parameters now can be resolved independently of the script.
But, as parameters are part of the script, their resolve will be called
before the script.

^KT-66276 Fixed
2024-03-07 12:50:59 +00:00
Dmitrii Gridin 150af66b55 [LL FIR] implement diagnostic tests on custom script definitions
it is impossible to declare test data with another output yet
as `myScriptFile.test.ll.kts` won't be treated as custom definition as
it requires `test.kts` extension.

^KT-66232 Fixed
^KT-66276
2024-03-07 12:50:59 +00:00
Jinseong Jeon 94e5653eb7 Migrate utils to check/alter TypeMappingMode according to suppress wildcard annotations
^KT-61734
2024-03-07 10:16:59 +00:00
Yan Zhulanow 4cbd431d22 [Pill] Enable Pill for scripting tests 2024-03-07 06:25:00 +00:00
Sergej Jaskiewicz 0008e832d8 [PowerAssert] Improve the accuracy of locating infix operator tokens
Use KotlinLexer to determine the correct offset of an infix operator
token instead of skipping whitespaces after the operator's LHS.

This fixes cases like this:

```
assert("Name"/*in*/in/*in*/listOf("Hello", "World"))
              |            |
              |            [Hello, World]
              false
```
2024-03-05 18:54:06 +00:00
Sergej Jaskiewicz 54c58671fb [PowerAssert] Correctly align infix calls for built-in operators
Instead of searching for the operator in the string representation of
the whole expression, consider the operator's start to be the
first non-whitespace non-dot character _after_ the LHS of the infix
expression.

This fixes cases like this:
```
assert("Name in " in listOf("Hello", "World"))
             |       |
             |       [Hello, World]
             false
```

^KT-66208 Fixed
2024-03-05 18:54:06 +00:00
Sergej Jaskiewicz 7d22825176 [PowerAssert] Reproduce KT-66208 2024-03-05 18:54:06 +00:00
Ilya Gorbunov 35bca103eb [stdlib-mpp] Single dependency on stdlib in commonMain
In this project it's required to declare stdlib dependency explicitly,
but now it can be a single line in commonMain
2024-03-04 11:40:06 +00:00
Nikita Klimenko 42cc181fa0 [FIR Plugin prototype] Implement DataFrame-like extension
Proof of concept that FirFunctionCallRefinementExtension (new) and
existing extension points can be used together to update the return type
of the specific calls and generate members based on call arguments.

Important implementation details:
- FirDeclarationGenerationExtension must be used to generate members of
generated local classes.
- FirExtensionSessionComponent together with firCachesFactory to pass
information between `intercept` and `transform`

Actual plugin is developed as a part of Kotlin dataframe repository

KT-65859
2024-03-04 06:33:24 +00:00
Brian Norman 721d02f4f3 [PowerAssert] Find the earliest starting offset for receiver expression
Calls of infix functions have a start offset which doesn't include the
receiver. Property accessors have a start offset at the start of the
property name and do not include their receiver expression. This
combination can cause problems when the entire expression needs to be
displayed, including the entirety of a complex receiver. Make sure to
navigate expressions to find their earliest starting offset and use that
instead.

^KT-65810 Fixed
2024-02-29 15:10:09 +00:00
Brian Norman d53d5dddc5 [PowerAssert] Add tests to recreate KT-65810 2024-02-29 15:10:09 +00:00
Brian Norman 78bb0be7aa [FIR2IR] Propagate NOT_IN statement origin when converting to IR
^KT-65636 Fixed
2024-02-29 15:10:09 +00:00
Brian Norman 6d634ac87f [PowerAssert] Mark project tests as using JUnit 5 2024-02-29 15:10:09 +00:00
Brian Norman f0268721c1 [PowerAssert] Use OS path separator to parse JUnit5 classpath property 2024-02-29 15:10:09 +00:00
Brian Norman 027474cfb8 [PowerAssert] Correctly align infix calls with string const receivers
^KT-65640 Fixed
2024-02-29 15:10:09 +00:00
Artem Kobzar 2e4d02e9f4 [PSI2IR, K/Wasm] Sync start and end offsets on PSI and FIR for primary constructors 2024-02-29 14:42:33 +00:00
Pavel Mikhailovskii 12552e4e04 [KAPT] KT-44706 Support @JvmRecord-annotated classes
Don't parse Java stubs in tests if no validation is needed

Merge-request: KT-MR-14308
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-02-29 12:44:56 +00:00
Kirill Rakhman 5e83350576 [Infrastructure] Assert dumps don't exist without directive
#KT-58697 Fixed
2024-02-29 08:36:16 +00:00
Roman Efremov 18176cb5ee Fix crash when compiler plugin generates top-level private suspend
...function.

^KT-61993 Fixed
2024-02-28 12:25:12 +00:00
Roman Efremov b2a2d32d70 [Test] Reproduce crash when plugin generates top-level private suspend
...function.

^KT-61993
2024-02-28 12:25:12 +00:00
Alexander Udalov 9d1d01d1eb jvm-abi-gen: Minor, deduplicate newField/newMethod calls 2024-02-28 10:19:45 +00:00
Vladimir Tagakov d2792533b8 jvm-abi-gen: Remove internal declarations from ABI
#KT-65690 Fixed
2024-02-28 10:19:45 +00:00
Marco Pennekamp 708ed81eb2 [Test] Avoid importing unused @Nested annotations in generated tests
- Unused `Nested` imports frequently cause unused import warnings in the
  IDE, which are especially annoying in after-commit warning/error
  analysis.
2024-02-27 20:30:06 +00:00