Commit Graph

16109 Commits

Author SHA1 Message Date
Artem Kobzar de880ce9aa [K/JS] Move ES modules logic to a new transformer with IC 2022-10-13 07:32:44 +00:00
Denis.Zharkov 31ba1f1534 Add deprecation warning for false-negative TYPE_MISMATCH
See KT-49404 for details

In K1, within SubstitutingScope we approximate almost all the types
containing captured types are being approximated to either a lower or
an upper bound.

While mostly, it's being done correctly there are some problems with
approximations for flexible types

So, the parameter's type of A<in Any>::foo is approximated to Inv<in Any!>,
thus allowing to use Inv<*>, while it's obviously unsound.

NB: For the similar example, in B, there are regular TYPE_MISMATCH
because parameter for B<in Any>::foo is approximated to Nothing

Also, it's important to say that
- in K2 everything works because we don't use type approximation there
- approximation algorithm that works incorrectly is only being used in K1

^KT-54332 Fixed
2022-10-12 20:53:02 +00:00
pyos 2ec264cfa2 FIR CFG: filter out variables declared inside lambdas more eagerly 2022-10-12 11:56:02 +00:00
Mikhail Glukhikh 0080f16cc2 K1: report TYPE_MISMATCH for incorrect assignments in builder
#KT-54004 Fixed
2022-10-12 08:21:13 +00:00
Mikhail Glukhikh 0940707fd4 FE: add reproducer for KT-54004 2022-10-12 08:21:12 +00:00
Pavel Mikhailovskii f4bdf54601 KT-8575 Fix warnings for Java synthetic properties 2022-10-10 22:03:58 +00:00
vladislav.grechko e0c8142106 Support of custom 'equals' and 'hashCode' in inline classes
'equals' from any made available for overriding in inline classes
'typed' equals made available for definition in inline classes
'typed' equals definition made compulsory if 'untyped' is overridden
'operator' keyword is allowed in 'typed' equals definition

^KT-24874: Fixed
2022-10-10 16:52:34 +00:00
Pavel Mikhailovskii 0947834f0d Add a test for KT-54318 2022-10-10 13:47:34 +02:00
Pavel Mikhailovskii 5fdfd4a421 Revert "KT-53146 Don't coerce Nothing? returned from "catch" clauses"
This reverts commit 903a5d69a4.
2022-10-10 13:36:44 +02:00
Nikolay Lunyak b6f950ed75 [FIR][FE 1.0] KT-47933: Warn about redundant @Repeatable
Merge-request: KT-MR-7318
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2022-10-07 13:33:49 +00:00
Evgeniy.Zhelenskiy 6117cdc0c3 [IR] Remove unused MFVC getters
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-10-07 12:43:46 +00:00
Evgeniy.Zhelenskiy 9dd308dc01 [IR] Add context receivers test, fix a flattening fields bug
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-10-07 12:43:46 +00:00
Evgeniy.Zhelenskiy e1f886936c [IR] Support try for MFVC
#KT-1179
2022-10-07 12:43:45 +00:00
Evgeniy.Zhelenskiy f8aa3612f8 [IR] Support if and when for MFVC, fix several bugs, refactor
#KT-1179
2022-10-07 12:43:44 +00:00
Evgeniy.Zhelenskiy 70293fab60 [IR] Rename MFVC tests + Add test for get-field optimization
#KT-1179
2022-10-07 12:43:43 +00:00
Evgeniy.Zhelenskiy ec3c0af09d [IR] Suppress temporary test failing on Android
Bug is fixed in https://jetbrains.team/p/kt/reviews/6452

#KT-1179
2022-10-07 12:43:42 +00:00
Evgeniy.Zhelenskiy 6f94af80ab [IR] Correct work of the new MFVC lowering classes
#KT-1179
2022-10-07 12:43:42 +00:00
Evgeniy.Zhelenskiy 8ba20bee5b [IR] Prepare MFVC-lowering for the new MFVC classes
#KT-1179
2022-10-07 12:43:41 +00:00
Evgeniy.Zhelenskiy eb0aa55571 [IR] Fix MFVC with type arguments/parameters
#KT-1179
2022-10-07 12:43:40 +00:00
Evgeniy.Zhelenskiy f9bed3d946 [IR] Support MFVC with type parameters
#KT-1179
2022-10-07 12:43:40 +00:00
Evgeniy.Zhelenskiy 14b8e41967 [IR] Integrate MFVC with Inline classes
#KT-1179
2022-10-07 12:43:39 +00:00
Evgeniy.Zhelenskiy 765c212327 [IR] Add MFVC generation tests
#KT-1179
2022-10-07 12:43:38 +00:00
Evgeniy.Zhelenskiy 894cdc2307 [IR] Implement equals call correct generation for MFVC
#KT-1179
2022-10-07 12:43:37 +00:00
Evgeniy.Zhelenskiy 0d350f94f2 [IR] Implement bridges generation for MFVC
#KT-1179
2022-10-07 12:43:37 +00:00
Evgeniy.Zhelenskiy 0c1c25e477 [IR] Implement MFVC basic flattening
#KT-1179
2022-10-07 12:43:36 +00:00
Evgeniy.Zhelenskiy d4969e9b97 Revert "rra/zhelenskiy/flattening_impl"
This reverts commit b7f5c039a6.
2022-10-07 12:43:36 +00:00
Evgeniy.Zhelenskiy dff949344d [IR] Remove unused MFVC getters
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-10-07 12:42:15 +00:00
Evgeniy.Zhelenskiy 5c0784fef5 [IR] Add context receivers test, fix a flattening fields bug
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-10-07 12:42:14 +00:00
Evgeniy.Zhelenskiy afe67f9bc1 [IR] Support try for MFVC
#KT-1179
2022-10-07 12:42:14 +00:00
Evgeniy.Zhelenskiy ca789607ba [IR] Support if and when for MFVC, fix several bugs, refactor
#KT-1179
2022-10-07 12:42:13 +00:00
Evgeniy.Zhelenskiy e76041bb3b [IR] Rename MFVC tests + Add test for get-field optimization
#KT-1179
2022-10-07 12:42:12 +00:00
Evgeniy.Zhelenskiy 2c50fef251 [IR] Suppress temporary test failing on Android
Bug is fixed in https://jetbrains.team/p/kt/reviews/6452

#KT-1179
2022-10-07 12:42:12 +00:00
Evgeniy.Zhelenskiy c2284d15a5 [IR] Correct work of the new MFVC lowering classes
#KT-1179
2022-10-07 12:42:11 +00:00
Evgeniy.Zhelenskiy 5ea1edf6d1 [IR] Prepare MFVC-lowering for the new MFVC classes
#KT-1179
2022-10-07 12:42:10 +00:00
Evgeniy.Zhelenskiy d0590e4e83 [IR] Fix MFVC with type arguments/parameters
#KT-1179
2022-10-07 12:42:10 +00:00
Evgeniy.Zhelenskiy cd432b1371 [IR] Support MFVC with type parameters
#KT-1179
2022-10-07 12:42:09 +00:00
Evgeniy.Zhelenskiy b1dced6cda [IR] Integrate MFVC with Inline classes
#KT-1179
2022-10-07 12:42:08 +00:00
Evgeniy.Zhelenskiy a788433aac [IR] Add MFVC generation tests
#KT-1179
2022-10-07 12:42:07 +00:00
Evgeniy.Zhelenskiy 73b0fac657 [IR] Implement equals call correct generation for MFVC
#KT-1179
2022-10-07 12:42:07 +00:00
Evgeniy.Zhelenskiy ee2d327243 [IR] Implement bridges generation for MFVC
#KT-1179
2022-10-07 12:42:06 +00:00
Evgeniy.Zhelenskiy 2896f5613d [IR] Implement MFVC basic flattening
#KT-1179
2022-10-07 12:42:06 +00:00
Evgeniy.Zhelenskiy 93ffd9f233 Revert "rra/zhelenskiy/flattening_impl"
This reverts commit b7f5c039a6.
2022-10-07 12:42:05 +00:00
Alexander Udalov 4dcf50d483 Fix reflection for repeated annotations with array arguments
This is related to 8308f5d7d3 (KT-44977).

It turns out that it's necessary to create `ArrayValue` with a
precomputed type not only in case of annotations stored directly in
Kotlin metadata (i.e. annotations on types and type parameters), but
also for arguments of repeated annotations. The reason is that repeated
annotations are stored in an array themselves, as an argument to another
(container) annotation. The annotation-reading code unwraps this array
to load repeated annotations as individual instances of
`AnnotationDescriptor`, but in contrast to loading normal annotations,
it doesn't set `source` to the reflection object, it uses `NO_SOURCE`
(see BinaryClassAnnotationAndConstantLoaderImpl.AbstractAnnotationArgumentVisitor.visitArray).

So when kotlin-reflect is later asked for the arguments of the
annotation, it needs to recreate the reflection object from
`AnnotationDescriptor` in `util.kt`. Doing so requires knowing the array
type, which is now present because we're creating a `TypedArrayValue`
(previously `DeserializedArrayValue`) in places where arrays are read as
annotation arguments.

Alternative solution would be to fix source passed to
`AnnotationDescriptorImpl` in the annotation-reading code, but that
seems a bit messy because the code is very abstract and is used in lots
of other places.

 #KT-53279 Fixed
2022-10-07 10:48:51 +00:00
Alexander Udalov 51ce829b96 Fix reflection class lookup in default package
Do not append "." to the name of the class in the default package.
2022-10-07 10:48:51 +00:00
pyos 46d7b66e59 FIR CFG: remove liveness analysis from lambda reassignment analyzer
Handling try/catch and break/continue is too hard here, and failing to
do that properly can create incorrect smartcast. Better be conservative
and assume all code is live.
2022-10-07 08:56:05 +00:00
pyos 3160470201 Minor: change a test to be more precise 2022-10-07 08:56:04 +00:00
pyos a9ae1fcdf9 FIR CFG: handle loops and try/catch when analyzing smartcasts in lambdas
See KT-50092
2022-10-07 08:56:04 +00:00
pyos d054617b8e FIR CFG: handle reassignments with explicit receivers more precisely
When a looping control structure has a reassignment with an explicit
receiver, we don't need to erase its smartcast info as it has to be a
non-local property and is thus automatically unstable anyway. However,
we should still do that upon reaching the assignment itself for slightly
more precise error messages (as the property not just "could be"
reassigned, but *has been* reassigned already).
2022-10-07 08:56:03 +00:00
pyos 77c2601382 Add a test where a local variable has the same name as a property 2022-10-07 08:56:02 +00:00
Evgeniy.Zhelenskiy b7f5c039a6 rra/zhelenskiy/flattening_impl
[IR] Remove unused MFVC getters

Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179

[IR] Add context receivers test, fix a flattening fields bug

Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179

[IR] Support `try` for MFVC

#KT-1179

[IR] Support `if` and `when` for MFVC, fix several bugs, refactor

#KT-1179

[IR] Rename MFVC tests + Add test for get-field optimization

#KT-1179

[IR] Suppress temporary test failing on Android

Bug is fixed in https://jetbrains.team/p/kt/reviews/6452

#KT-1179

[IR] Document the new MFVC lowering classes when necessary

#KT-1179

[IR] Correct work of the new MFVC lowering classes

#KT-1179

[IR] Prepare MFVC-lowering for the new MFVC classes

#KT-1179

[IR] Fix MFVC with type arguments/parameters

#KT-1179

[IR] Support MFVC with type parameters

#KT-1179

[IR] Integrate MFVC with Inline classes

#KT-1179

[IR] Fix compilation of MFVC in different module

#KT-1179

[IR] Add MFVC generation tests

#KT-1179

[IR] Implement equals call correct generation for MFVC

#KT-1179

[IR] Implement bridges generation for MFVC

#KT-1179

[IR] Implement MFVC basic flattening

#KT-1179

Merge-request: KT-MR-6213
Merged-by: Evgeniy Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>
2022-10-06 20:45:45 +00:00