Commit Graph

4875 Commits

Author SHA1 Message Date
Pavel Mikhailovskii 906c161068 KT-52791 Make it possible to pass multiple context receivers to a class 2022-12-28 11:21:03 +00:00
Pavel Mikhailovskii 3704d54101 KT-52459 Handle context receivers when generating a bridge 2022-12-27 16:19:59 +00:00
Pavel Mikhailovskii 076bedd065 KT-51397 Add a test (has been fixed elsewhere) 2022-12-27 12:50:43 +00:00
Pavel Mikhailovskii 9ca5e1b421 KT-54357 Fix passing of context receivers to object literal constructors 2022-12-27 11:52:36 +00:00
Ilya Gorbunov e2d96da396 Introduce experimental kotlin.concurrent.Volatile annotation KT-55268, KT-55609
Use this annotation in tests to ensure it works the same at least on JVM
2022-12-23 19:07:30 +01:00
Xin Wang 7278f9a4fd JVM Inline: Update tryCatchBlocks when expand mask conditions
Fixes: KT-48989
2022-12-22 12:50:41 +00:00
Pavel Mikhailovskii 06d3e1d8bd KT-55005 Do not generate CHECKCAST before AASTORE 2022-12-21 15:06:07 +00:00
Dmitriy Novozhilov 02e327277e [FIR] Report VAL_REASSIGNMENT on assign to non-local vals
In this commit reporting on member properties in init section of class
  is not supported (see KT-55528)

^KT-55493 Fixed
2022-12-20 08:12:09 +00:00
Evgeniy.Zhelenskiy 53b98503ed [IR] Support MFVC properties without backing fields
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-12-18 22:11:23 +00:00
Igor Chevdar 0f2ebeea15 [tests] Added a test for KT-55494 2022-12-16 18:32:42 +00:00
mcpiroman a244aaf162 KT-53957 Fix indy lambdas with extension and context receivers (#5021) 2022-12-16 17:47:58 +01:00
Steven Schäfer 6af616d3c3 FIR: make declarations marked with 'override' implicitly open
#KT-52236 Fixed
2022-12-14 21:46:41 +00:00
Sergej Jaskiewicz 9c6f92d697 [test] Add a test for KT-55318 2022-12-13 17:01:00 +00:00
Denis.Zharkov fd7559893e Fix deserialization exception for DNN types from Java
useCorrectedNullabilityForTypeParameters = true only might lead
to something becomes a DNN when otherwise it wasn't.

It seems safe to use it here, since if compiler has generated DNN, then
it's OK to assume that it checked necessary conditions, and it's likely
that it had useCorrectedNullabilityForTypeParameters = true as well, there.

Anyway, it looks saner than having an exception here.

Also, we assume here that metadata leading to exception might only be generated
with ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated LF
(at least, we don't have contradicting evidences),
thus it's mostly a preparations in case we decide to enable
ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated in 1.9.

^KT-55357 Fixed
^KT-55388 Related
^KT-36770 Related
2022-12-12 12:42:14 +00:00
Denis.Zharkov 9e8e5c5a36 Make sure that fix for KT-53041 works with additional LF
Previously, it worked by default because ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
was enabled by default since 1.8, but we have to disable it because of KT-55357

Turning off the fix by default is not a breaking change per se, because
1.8 has not yet been released.

^KT-55357 Related
^KT-36770 Related
^KT-53041 Open
2022-12-12 11:39:05 +00:00
Evgeniy.Zhelenskiy f09fb5ed09 [IR] Enable tests for inline classes secondary constructors with body for not JVM
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-55333
2022-12-11 22:06:47 +01:00
Evgeniy.Zhelenskiy abc1d942d1 [IR] Add tests for value classes secondary constructors with body and set language feature version for the feature
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-55333
2022-12-11 22:06:47 +01:00
Pavel Mikhailovskii 1a76804862 KT-51290 Account for context receivers when generating delegate function bodies 2022-12-09 15:36:45 +00:00
Pavel Mikhailovskii 08767d572b KT-51247 Fix resolution of functional types with context receivers 2022-12-09 15:29:39 +00:00
Pavel Mikhailovskii a4bde57d44 KT-51475 Add a test 2022-12-09 15:27:59 +00:00
Pavel Mikhailovskii 57ddb9fddf KT-53846 Pass context receivers to secondary constructors 2022-12-09 15:24:56 +00:00
Dmitriy Novozhilov 3cffb33ab7 [FE] Drop ApproximateIntegerLiteralTypesInReceiverPosition language feature
This feature is not needed because it is unconditionally disabled for K1
  (because of not fully correct implementation) and unconditionally enabled
  in K2 (K2 does not support old behavior)

^KT-38895
2022-12-09 15:10:02 +00:00
Dmitriy Novozhilov 9946bfcdfd [FIR2IR] Properly handle error references in generation of receivers
^KT-53698 Fixed
2022-12-09 12:02:06 +00:00
Dmitriy Novozhilov f3da26946b [FIR] Change priority of K2_VISIBILITY_ERROR CandidateApplicability
In K1 analogue of `K2_VISIBILITY_ERROR` is `K1_RUNTIME_ERROR`, so
  candidates with `K2_VISIBILITY_ERROR` should win over innaplicable
  candidates with `INAPPLICABLE`, `INAPPLICABLE_ARGUMENTS_MAPPING_ERROR`
  or `INAPPLICABLE_WRONG_RECEIVER` applicability

This is needed to allow resolution to invisible symbols (and later
  suppress error with `@Suppress("INVISIBLE_SYMBOL", "INVISIBLE_REFERENCE")`

^KT-55026 Fixed
^KT-55234
2022-12-09 12:02:05 +00:00
Dmitriy Novozhilov 6c6525ecde [FIR] Add test for KT-55026 2022-12-09 12:02:04 +00:00
Pavel Mikhailovskii b31209a38a KT-51951 Add a test 2022-12-09 09:47:23 +00:00
Pavel Mikhailovskii 76997edebe KT-52373 Fix generation of synthetic functions with context receivers and default parameters 2022-12-09 09:39:26 +00:00
Evgeniy.Zhelenskiy 40f38c8adb [IR] Eliminate redundant boxing/unboxing of MFVC after inlining
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-12-08 15:12:28 +00:00
pyos c4c05f5248 FIR CFG: remove ordering from control flow through in-place lambdas
Old graph:

  arg -> lambda enter -> ... -> lambda exit -> lambda enter -> ... ->
   -> lambda exit -> call

New graph:

  arg -+-> lambda enter -> ... -> lambda exit -+-> call
       \-> lambda enter -> ... -> lambda exit -/
2022-12-08 10:19:31 +00:00
pyos a9be27e330 FIR CFG: add union nodes
Quick quiz:

 Q: In a CFG, what does `a -> b -> c -> d` mean?
 A: `a`, then `b`, then `c`, then `d`.

 Q: In a CFG, what does `a -> b -> d; a -> c -> d` mean?
 A: `a`, then `b` or `c`, then `d`.

 Q: So how do you encode "a, then (b, then c) or (c, then b), then d`?
 A: You can't.

Problem is, you need to, because that's what `a; run2({ b }, { c }); d`
does when `run2` has a contract that it calls both its lambda arguments
in-place: `shuffle(listOf(block1, block2)).forEach { it() }` is a
perfectly valid implementation for it, as little sense as that makes.

So that's what union nodes solve. When a node implements
`UnionNodeMarker`, its inputs are interpreted as "all visited in some
order" instead of the normal "one of the inputs is visited".

Currently this is used for data flow. It *should* also be used for
control flow, but it isn't. But it should be. But that's not so easy.

BTW, `try` exit is NOT a union node; although lambdas in one branch can
be completed according to types' of lambdas in another, data does not
flow between the branches anyway (since we don't know how much of the
`try` executed before jumping into `catch`, and `catch`es are mutually
exclusive) so a `try` expression is more like `when` than a function
call with called-in-place-exactly-once arguments. The fact that
`exitTryExpression` used `processUnionOfArguments` in a weird way
should've hinted at that, but now we know for certain.
2022-12-08 10:19:29 +00:00
pyos 16b8811697 FIR DFA: take all statements from ?. if result is non-null.
I.e. a?.f(b as T) != null => b is T.

This also allows to remove the copyAllInformationFrom hack by moving the
edge directly in the control flow graph.
2022-12-08 10:19:28 +00:00
pyos 0d46dfc1ba FIR: fix substitution of type arguments in SAM type aliases
^KT-54730 Fixed
2022-12-07 22:09:20 +00:00
Pavel Mikhailovskii 4676072137 KT-51284 Fix SAM conversion for methods with context receivers 2022-12-07 09:01:21 +00:00
Pavel Mikhailovskii 2d69fd5a8a KT-52027 Encapsulate and fix calculation of parameter indices 2022-12-06 23:16:11 +00:00
Pavel Mikhailovskii 25ad7fe31c KT-51863 Account for context receivers in calls with changed parameter order 2022-12-06 16:28:08 +00:00
Mikhail Glukhikh 5cf1a88c42 FE: move delegate name functions to NameUtils 2022-12-02 21:54:18 +00:00
Vladislav Grechko cb93e9d408 Get rid of redundant boxing of unsigned operands of infix 'compareTo'
^KT-48759: Fixed
2022-12-02 18:25:52 +00:00
Dmitriy Novozhilov 1281b778fb [Test] Fix broken testdata 2022-12-01 14:47:24 +02:00
Dmitriy Novozhilov 6b343515e1 [Test] Save IR bytecode dumps from BytecodeListingHandler to .ir.txt file instead of _ir.txt
This is needed to keep consistency with other dumps and to allow
  test helper plugin to recognize those dumps
2022-12-01 07:29:37 +00:00
Pavel Mikhailovskii f96d41e414 KT-4107 Don't generate readResolve for data objects 2022-11-30 21:07:20 +00:00
Evgeniy.Zhelenskiy fa4a4e56f3 [Tests] Remove unnecessary usages of OPTIONAL_JVM_INLINE_ANNOTATION
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:42 +00:00
Evgeniy.Zhelenskiy 50310d42e3 [IR] MFVC lateinit variables and properties test
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:42 +00:00
Evgeniy.Zhelenskiy b7f249cdb6 [IR] Fix bugs in MFVC function references support
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:41 +00:00
Evgeniy.Zhelenskiy 68fb8aa2a1 [IR] Replace indexes with names for mfvc methods and fields
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:41 +00:00
Evgeniy.Zhelenskiy b692748938 [IR] Always add getter methods to value classes even if not used
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:40 +00:00
Evgeniy.Zhelenskiy 3653c86f08 [IR] Rename static replacement of MFVC typed equals to "equals-impl0"
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:40 +00:00
Evgeniy.Zhelenskiy 38c80192f9 [IR] Support MFVC-typed properties and interfaces delegates
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:40 +00:00
Evgeniy.Zhelenskiy 4d426fc4cd [IR] Generate not FIR_IDENTICAL box fir value classes tests
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:39 +00:00
Evgeniy.Zhelenskiy adee33d3e5 [IR] Forbid MFVC primary constructors default arguments
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:38 +00:00
Evgeniy.Zhelenskiy c6e54e6433 [IR] Support object-like interaction with MFVC function references
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:37 +00:00