Commit Graph

7582 Commits

Author SHA1 Message Date
Ivan Kochurkin b72dcf8b37 [K2, MPP] Fix actualization of nullability-based overloads
^KT-58043 Fixed
2023-04-20 17:22:45 +00:00
Kirill Rakhman e80b4c530d [FIR2IR] Properly handle intersection types in interface delegation
The changes to the irText test data result in the fact that we
now unconditionally unwrap substitution overrides of delegation targets
whereas before we built an unsubstituted scope of the type we delegate
to. If we delegate to a class A : B<C>, the unsubstituted scope of
A can still contain substitution overrides for inherited generic methods
from B<T> that we didn't unwrap before but do unwrap now.

#KT-57899 Fixed
2023-04-20 08:12:55 +00:00
Kirill Rakhman 35c6da1aa7 [FIR2IR] Fix and refactor generation of dynamic call receiver generation
#KT-57988 Fixed
2023-04-20 08:04:07 +00:00
Ivan Kylchik 6b75b3bc4a [IR] Drop duplicated meta info from interpreters tests 2023-04-19 13:52:48 +00:00
Ivan Kylchik 3f60c83921 [IR] Add id method in interpreter's tests to avoid optimizations 2023-04-19 13:52:48 +00:00
Ivan Kylchik 621f5a0fb7 [IR] Reorganize test files in involvesIrInterpreter dir 2023-04-19 13:52:48 +00:00
Ivan Kylchik c00c7ffbe0 [K2] Use file name as one of parameters to extract evaluated const
It is not enough to store evaluated constants only by
<startOffset, endOffset> pair. We need to consider case there constant
can be located in different files with the same offset but with
different values.

#KT-57928 Fixed
#KT-57929 Fixed
2023-04-19 13:52:46 +00:00
Ivan Kylchik 8cc8e54a9f [IR] Extract toString interpretation test of float value into new file
We need to distinguish `toString` results for JVM and JS
2023-04-19 13:52:46 +00:00
Ivan Kylchik 1ddcdcfc39 [IR] Rewrite logic around object interpretation
Basically we want to allow object interpretation only when we try
to access some const val property.

#KT-57810 Fixed
2023-04-19 13:52:44 +00:00
Ivan Kylchik 5956e9b500 [IR] Print evaluated const directly into interpreter's tests 2023-04-19 13:52:44 +00:00
Ilya Chernikov 8cc9f911d5 FIR: temp: make klib symbol provider know parent packages
Current qualified access resolving algo rely (likely incorrectly,
see #KT-58037) on a providers' "knowledge" about parent packages.
This commit adds this "knowledge" to k-lib based provider.
#KT-57353 fixed
2023-04-19 11:42:03 +00:00
Pavel Mikhailovskii 3bb66e8432 KT-57714 Fix remapping of signatures with reified type parameters 2023-04-19 07:20:51 +00:00
Kirill Rakhman ff7072830f [FIR] Make lambda parameters of dynamic function calls dynamic
#KT-57961 Fixed
2023-04-18 13:43:45 +00:00
Alexander Korepanov 79d378f2bd [JS IR] Perform optimizations on the generated JS code
The patch adopts and reuses the optimizations from the legacy backend.

The optimizations remove useless temporary variables,
statements and simplify generated JS code.

The optimizations can be disabled by `-Xoptimize-generated-js=false`.

Related to KT-51139
2023-04-18 12:49:33 +00:00
Svyatoslav Scherbina 54c07f5ebb Ignore K2 expectPropertyAsDefaultArgument.kt test for K1/Native
It is not supposed to work with K1 on Native due to test infrastructure
limitations, and actually fails in one of the compilation modes in
nightly tests.
2023-04-18 10:43:51 +00:00
Mikhail Glukhikh bde0282fb1 K2: extract constant from Java enum entry properly
#KT-58002 Fixed
2023-04-17 21:05:04 +00:00
Mikhail Glukhikh 0a126a173e K2: reproduce KT-58002 2023-04-17 21:05:03 +00:00
Mikhail Glukhikh 5cff8c15ab K2: fix intrinsic analysis in FirToConstantValueChecker
#KT-57986 Fixed
2023-04-17 20:53:31 +00:00
Mikhail Glukhikh c826c7301c K2 JS/Native: reproduce KT-57986 2023-04-17 20:53:30 +00:00
Ivan Kochurkin beaeb405d2 [K2, MPP] Build expect-actual map for type parameters from functions
^KT-57181 Fixed
2023-04-17 19:55:35 +00:00
Ivan Kochurkin b7bb9c317f [K2, MPP] Introduce FunctionDefaultParametersActualizerVisitor and use it in FunctionDefaultParametersActualizer
^KT-57263 Fixed
2023-04-17 19:55:34 +00:00
Nikita Bobko 5a96754aec Shift ReferencesToSyntheticJavaProperties feature release from 1.9 to 2.1
Other related tests:
- testGenericJavaProperty
- testFunInterfaceConstructorReference

Meta issue: KT-8575
Review: https://jetbrains.team/p/kt/reviews/9595

UnsupportedSyntheticCallableReferenceChecker only existed for K1,
because we wanted to release the feature for 1.9 and the feature should
have been working for K2 unconditionally. But since, we're postponing
the release until 2.1, we also need to port the checker from K1 to K2
2023-04-17 17:42:01 +00:00
Zalim Bashorov 521a272acb [Wasm] Pass js stack value directly when replacing a wasm exception with JS one
In this case, we don't need to convert a value to and from wasm String.
2023-04-17 16:15:22 +00:00
Zalim Bashorov 6bfd1e7e9f [Wasm] Stop using unsigned numbers in ScopedMemoryAllocator
It turned out that using unsigned numbers is heavy both in terms of size and performance.
We can consider switching back (KT-58041) as soon as we implement unsigned numbers and operations using wasm built-in capabilities (KT-58039).
2023-04-17 16:15:22 +00:00
Zalim Bashorov c114afb55d [Wasm] export __callFunction_* only when a respective closure/lambda converter is used 2023-04-17 16:15:21 +00:00
Evgeniy.Zhelenskiy aceab2ac1f [IR] Fix KT-57973
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-57973
2023-04-17 12:33:10 +00:00
Evgeniy.Zhelenskiy 8c748bfea4 [IR] Add more tests for inline/value classes secondary constructors
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-55333
2023-04-17 12:10:14 +00:00
Ivan Kochurkin 9a09565cf6 [K2, MPP] Handle overloaded properties
^KT-57532 Fixed
2023-04-12 20:43:57 +00:00
Kirill Rakhman 592baee852 [FIR] When call candidates resolve to errors, select the least bad ones
This fixes a scenario when INVISIBLE_REFERENCE is suppressed, but we
resolved to the wrong overload because when none of the candidates were
applicable, more or less the first one was chosen.

Because we call `fullyProcessCandidate` on the candidates, their
applicability can change which can lead to a situation where the
applicability of a ConeAmbiguityError is different to all its
candidates. The changes in coneDiagnosticToFirDiagnostic.kt account for
that, otherwise code like candidates.first { it.applicability ==
CandidateApplicability.UNSAFE_CALL } can throw NoSuchElementException.

#KT-57776 Fixed
2023-04-12 14:03:39 +00:00
Igor Yakovlev edf4e80165 [Wasm] Fix for ReturnableBlockLowering invalid ir type for converted inlined blocks 2023-04-12 13:24:02 +00:00
Kirill Rakhman aab1959cc4 [FIR2IR] Fix codegen for lambda with dynamic receiver
#KT-57835 Fixed
2023-04-12 13:10:43 +00:00
Nikolay Lunyak caa7bee917 [FIR] KT-57835: Prevent the compiler crash
^KT-57835 Fixed
2023-04-12 10:20:44 +00:00
Ivan Kylchik 08ba63df90 Implement proper name interpretation for suspend functions
#KT-57313 Fixed
2023-04-11 21:28:13 +00:00
Dmitriy Novozhilov af05646fe3 [FIR] Don't expand typealiases in annotations during type deserialization
During extracting type attributes from annotations we should expand
  typealiases of annotation type to handle cases when user makes a typealias
  on some special annotation, like `kotlin.internal.Exact`. And to exapnd
  typealias we should resolve annotation class id to symbol.
This leads to a cycle during class deserialization, if some nested annotation
  is used as type annotation in some declaration in the same class

```
interface SomeInterface {
    interface NestedInterface : @Ann Some

    interface Some

    @Target(AnnotationTarget.TYPE)
    annotation class Ann
}
```
Attempt to find symbol for SomeInterface.Ann during deserialization of
  SomeInterface.NestedInterface wil lead to second attempt to deserialize
  class SomeInterface, which eventually leads to StackOverFlow. And at the
  same time expanding typealiases for annotations from binaries has not
  much sense, because types in binaries are already expanded

So to fix this issue it's enough to just not expand typealiases on type
  annotations for types of deserialized declarations

^KT-57876 Fixed
2023-04-11 16:02:57 +00:00
Abduqodiri Qurbonzoda b65a68ca0d [K/N and WASM] Internalize NoWhenBranchMatchedException and UninitializedPropertyAccessException
As a part of efforts to stabilize Native stdlib.

Merge-request: KT-MR-9531
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2023-04-10 21:10:51 +00:00
Ilya Gorbunov b8da3e69ce KT-55268 Make k.c.Volatile stable 2023-04-08 15:07:56 +00:00
Ivan Kylchik ac480e2285 [K2] Support serialization of complex annotations
#KT-57611 Fixed
2023-04-07 18:07:09 +00:00
Ivan Kylchik 4a50bd9b16 [K2] Fix annotation serialization for simple cases
#KT-57611
2023-04-07 18:07:09 +00:00
Sergej Jaskiewicz 4b6975c3d0 [fir2ir] Set origins for componentN and copy methods of data classes
This aligns the behavior with psi2ir.
2023-04-06 14:45:47 +00:00
Zalim Bashorov 46459dfa60 [Wasm] Minor: update expected size after rebase 2023-04-05 20:50:52 +02:00
Zalim Bashorov 9760e3ee1e [Wasm] Introduce check and error specialized for String to reduce output size 2023-04-05 20:50:52 +02:00
Zalim Bashorov 295acdf2af [Wasm] Rewrite lazy initialization without by lazy and lateinit to reduce overhead 2023-04-05 20:50:52 +02:00
Zalim Bashorov 1a8a4fa65d [Wasm] Don't use by lazy inside Throwable 2023-04-05 20:50:52 +02:00
Zalim Bashorov 67357fa5d4 [Wasm] Replace heavyweight stackTraceToString with "pure" JS stack 2023-04-05 20:50:52 +02:00
Zalim Bashorov 14af47bbd9 [Wasm] Introduce utilities to get package and name of class directly from metadata and use it in some places 2023-04-05 20:50:52 +02:00
Zalim Bashorov a9b553f16e [Wasm] Don't use by lazy to keep some JS values used by adapters 2023-04-05 20:50:52 +02:00
Zalim Bashorov 494403c4bb [Wasm] Don't use by lazy inside TeamcityAdapter 2023-04-05 20:50:52 +02:00
Zalim Bashorov 2ef47901d0 [Wasm] Introducing private identityHashCode shared between Any's hashCode and toString
It splits the dependency of toString from hashCode that prevents keeping hashCode when toString is used.
2023-04-05 20:50:51 +02:00
Zalim Bashorov 6e3eef7a88 [Wasm] add simple tests to track the size of wasm and mjs files 2023-04-05 20:50:51 +02:00
Sergej Jaskiewicz 3713d95bb1 [klib] Don't deserialize the list of sealed subclasses from klibs
tl;dr the current design of klibs does not allow to properly deserialize
the list of sealed subclasses in a sound way. It is possible that
a subclass of a sealed class is declared in a different file, AND is
private in that file.

A more detailed explanation:

Right now we don't serialize file signatures at all.
However, a private declaration's signature must necessarily include
the file signature.

How do we serialize a private declaration's signature into a klib
and deserialize it later?

**Serialization** is simple: we just serialize the file signature as
an empty protobuf message.

When we are **deserializing** a private declaration, we look at the file
that is being deserialized right now, and construct the file signature
based on that.

This logic, however, doesn't always work. An example is KT-54028.

Basically, if we have a sealed interface with a private implementor
declared in a different file, this breaks:

1. We are deserializing the sealed interface. The deserializer knows
that we are now in the file in which the sealed interface is declared.
2. As part of deserializing the interface, we deserialize its sealed
subclasses.
3. Naturally, we come to deserializing the private implementor that is
declared in another file, but the deserializer still thinks that we are
in the file in which the interface is declared. A wrong signature is
created, which leads to linkage failure.

We *could* fix this by properly serializing the file signature,
i.e. instead of an empty protobuf message we could write the file path
and its package to the klib. However, there a problems with this
approach:

- The current design of signatures allows a situation where two
different files can have the same relative path
(for example, with the help of the `-Xklib-relative-path-base` compiler
flag) *and* the same package, which would introduce ambiguity during
linkage.
- Most importantly, this appoach won't work well with incremental
compilation of klibs. Currently we rely on the assumption that all
cross-file references are handled with public signatures, and private
signatures are only used inside a single file. This allows to move
declarations across files without recompiling it's use sites.

It has been decided to apply the following hacky solution: we just don't
deserialize the list of sealed subclasses from klibs.
The list of sealed subclasses is not used in lowerings, so it should be
safe.

#KT-54028 Fixed
2023-04-05 15:51:54 +00:00