Commit Graph

8267 Commits

Author SHA1 Message Date
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
Dmitriy Novozhilov 92a59279d5 [FIR] Properly implement serializer extension for klib compilation
^KT-57654 Fixed
2023-04-05 07:31:33 +00:00
Igor Yakovlev 44190937b0 [Wasm] Fix generic call return type for functions with default parameters 2023-04-04 18:39:18 +00:00
Igor Yakovlev 993334e5e4 [Wasm] Support feature InstantiationOfAnnotationClasses 2023-04-04 18:39:17 +00:00
Ivan Kylchik 32297c0f21 Serialize and deserialize const val's properly for K2 klib
#KT-57312 Fixed
2023-04-04 12:35:54 +00:00
Pavel Kunyavskiy 09474758ab [K/N] Fix typo in language feature name 2023-04-04 09:13:36 +00:00
Dmitriy Novozhilov d7d7620db2 [FIR2IR] Correctly calculate signature for non-dynamic calls on dynamic receiver
If dispatch receiver is dynamic and call on it is not dynamic that means
  that this call was resolved to some specific declaration because of
  smartcast. So we should use original type of this declaration as
  dispatch receiver during calculation of IdSignature instead of Any
  (which came from dynamic type). Otherwise we will have two different
  signatures for the same member declaration

^KT-57682 Fixed
2023-04-03 12:20:01 +00:00
Nikolay Lunyak f0720c1d12 [FIR] Fix K2 behavior according to RULES1
The compiler should only report diagnostics for
comparisons over builtins and identity-less types,
other incompatibilities should be reported
via inspections.

It's ok that in `equalityChecksOnIntegerTypes`
instead of `EQUALITY_NOT_APPLICABLE_WARNING` we get
`EQUALITY_NOT_APPLICABLE`, because
`ProperEqualityChecksInBuilderInferenceCalls`
is already active by default.

This change also replaces the notion of a representative superclass
with the least upper bound.
This makes complex types like
intersection/flexible transparent to
RULES1-based compatibility checks.
One way to look at it is to think
that this is an automatic way of handling
type parameters: automatic picking of
"interesting" bounds, and checking them against one another.

Note that `TypeIntersector.intersectTypes`
for `Int` and `T` where `T` is a type parameter
may return both `{Int & T}` or `null`
depending on `T`-s bounds. At the same time,
for type parameters `T` and `K` it will
always return `{T & K}`.

`ConeTypeIntersector.intersectTypes`, on the
other hand, will always return `{Int & T}`
irrespectively of the bounds. Meaning, the two
intersectors differ in corner cases.

`lowerBoundIfFlexible` call in `isLiterallyTypeParameter` is backed by
the `equalityOfFlexibleTypeParameters` test.

^KT-35134 #fixed-in-k2
^KT-22499 #fixed-in-k2
^KT-46383 #fixed-in-k2
2023-03-31 15:01:50 +00:00
Alexander Udalov 37c776b233 Add JVM target bytecode version 20
#KT-57495 Fixed
2023-03-30 19:05:41 +00:00
Vladimir Sukharev 351588f0a7 [K2/N] Enable some fixed MPP tests
Merge-request: KT-MR-9364
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-28 16:49:57 +00:00
Kirill Rakhman 32cc28c6cf [FIR] Skip expect-actual rules check when overriding non-expect member
Overriding equals, hashCode, toString and any other member that is not
expect does not require satisfying the rules of expect-actual matching.

#KT-57381 Fixed
2023-03-28 16:21:33 +00:00
Kirill Rakhman ee78c31174 [FIR2IR] Fix generation of Any method call on expect receiver
#KT-57583 Fixed
2023-03-28 12:47:42 +00:00
Mikhail Glukhikh 563781a246 K2: serialize data class equals / hashCode / toString functions
#KT-57510 Fixed
2023-03-28 09:30:02 +00:00
Vladimir Sukharev 9df5c54db3 [K2/N] KT-55828: Enable fixed tests
Merge-request: KT-MR-9246
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-27 17:25:54 +00:00
Vladimir Sukharev b375307aa6 KT-57349: Disable target-wide tests for K1/Native
Merge-request: KT-MR-9353
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-27 13:32:18 +00:00
Alexander Udalov e56e058b7b JVM IR: replace unoverridden Number.toChar with toInt().toChar()
This fixes failing tests for JVM_IR in
`box/primitiveTypes/numberToChar`.

 #KT-23447 Fixed
 #KT-46465
2023-03-27 10:46:15 +00:00