Commit Graph

18361 Commits

Author SHA1 Message Date
Svyatoslav Kuzmich 15d3bf5e25 [Wasm] Port JS interop type checker to K2 (KT-56849) 2023-10-31 12:34:32 +00:00
Mikhail Glukhikh 290adda8fc Calculate empty array literal types in FIR2IR instead of deserializer
This commit handles situations when some annotation in deserialized code
has an empty array literal argument [] or even non-empty [something].
Before this commit, we tried to guess a type of this array by "resolving"
the relevant annotation class and looking into the corresponding
parameter. Sometimes it can work, but also it can provoke recursive
resolve e.g. when the annotation class is a nested class in the same scope.
In this commit we changed the behavior in the following way:
- first, for non-empty array literals in deserialized code we just
take the array type from the corresponding array literal element
- second, for empty array literals we no more try to "guess" anything.
Instead we approximate array type as Array<Any>, and later at FIR2IR
stage we use the corresponding parameter type instead. At FIR2IR stage,
everything is already resolved and problems with recursions are no more
possible.

#KT-62598 Fixed
2023-10-31 12:30:29 +00:00
Mikhail Glukhikh 19a95f2fb4 K2: swap heuristics in AnnotationLoader (related to KT-62598)
Before this commit, we first tried to guess a type of array literal
in deserialized annotation (it's a strange heuristics which can
lead to SOE and maybe not needed at all, see KT-62598, KT-62929),
and then, if unsuccessful, took the type from the first literal element,
if any. Since the second heuristic is much more clear, safe, and
understandable, in this commit they were swapped.

This commit does not fix KT-62598 in general case,
but decreases a set of cases when it can occur to
empty array literals only.
See the commented line at the end of the added test.
2023-10-31 12:30:29 +00:00
Nikolay Lunyak f5d859f209 [FIR] Don't miss smartcast info on equalities with when subjects
Since they are not `FirSmartCastExpression`s,
they are treated as proper original types,
thus leading to reporting errors instead of
warnings.

^KT-60095 Fixed
2023-10-31 10:40:43 +00:00
Alexander Udalov 4f96171716 K2: report IR_WITH_UNSTABLE_ABI_COMPILED_CLASS
Also, remove setting the value of allowUnstableDependencies to true if
K2 is used because we want K2 to report errors (as K1 does) on
unstable-ABI dependencies.

 #KT-61598 Fixed
2023-10-31 10:39:43 +00:00
Brian Norman 01a757cbd6 [FIR] Report PROPERTY_WITH_NO_TYPE_NO_INITIALIZER for all properties
Currently, PROPERTY_WITH_NO_TYPE_NO_INITIALIZER is reported for local
variables, but not reported for member or top-level properties. Add a
check to the common `checkPropertyInitializer` for when a property
type cannot be determined from the getter.

This also corrects a K1 versus K2 inconsistency, where K2 would allow
blocks from getters to determine property type instead of only allowing
expression bodies.

^KT-59935 Fixed
^KT-60117 Fixed
^KT-60123 Fixed
2023-10-30 16:28:10 +00:00
Evgeniy.Zhelenskiy 756cd25417 [FIR] Support typed projections in exposed visibility declaration checker
#KT-62925
2023-10-30 07:22:34 +00:00
Evgeniy.Zhelenskiy a836e6bf29 [FIR] Support flexible types and star projections in exposed visibility declaration checker
#KT-62925
2023-10-30 07:22:34 +00:00
Nikolay Lunyak ed8935899c [FIR] Relax incompatibleEnumAndUnrelatedInterface 2023-10-30 06:58:40 +00:00
Nikolay Lunyak 8ec7d128f5 [FIR] Add one more missed case 2023-10-30 06:58:40 +00:00
Nikolay Lunyak c6bec2fa75 [FIR] Relax incompatibleEnumAndUnrelatedInterfaceThroughTypeParameter 2023-10-30 06:58:40 +00:00
Nikolay Lunyak 3058f2eaff [FIR] Relax incompatibleEnumComparisonWithTypeParameters 2023-10-30 06:58:40 +00:00
Nikolay Lunyak ae521524d6 [FIR] Add tests highlighting false errors in K2 regarding equalities
Some overlooked corner-cases found by Denis.
2023-10-30 06:58:39 +00:00
Anastasia.Nekrasova 86e175bbf1 [K2] Disappeared KCLASS_WITH_NULLABLE_TYPE_PARAMETER_IN_SIGNATURE
^KT-59992
2023-10-30 06:42:00 +00:00
Ilya Chernikov 1d461684ae LT: make where clause with errors parsing same as with PSI
- do not fail on the missing terms
- propagate invalid name to avoid reporting dangling constraints

#KT-58455 fixed
2023-10-27 18:22:28 +00:00
Kirill Rakhman 2613a337ae [FIR] Improve symbol rendering in *_NOT_IMPLEMENTED diagnostics 2023-10-27 13:27:35 +00:00
Kirill Rakhman 44a4498ee5 [FIR] Report ABSTRACT_MEMBER_NOT_IMPLEMENTED_BY_ENUM_ENTRY on enum entries with initializer
#KT-59577 Fixed
2023-10-27 13:27:35 +00:00
Kirill Rakhman 8821f8d1a4 [FIR] Expand type alias when checking for type parameters from outer declaration
This fixes a false positive OUTER_CLASS_ARGUMENTS_REQUIRED when
referring to an inner class of a supertype that is extended using a
typealias.

#KT-62099 Fixed
2023-10-27 08:05:58 +00:00
Kirill Rakhman 907ebb36d0 [FIR] Filter out SAM constructors from MemberScopeTowerLevel
This tower level is for calls on a dispatch receiver, and it's not
allowed to call SAM constructors on a dispatch receiver.

#KT-60983 Fixed
2023-10-27 08:03:00 +00:00
Evgeniy.Zhelenskiy a77349edb4 [FIR] Report INAPPLICABLE_INFIX_MODIFIER on vararg parameter, position INAPPLICABLE_INFIX_MODIFIER on infix keyword
#KT-59974
2023-10-26 20:07:50 +00:00
Mikhail Glukhikh f82c3c3bf7 K2: add test confirming finished migration in KT-33917
Related to KT-62918, KT-60086
2023-10-26 19:41:13 +00:00
Mikhail Glukhikh dda7004d66 K2: add test to confirm behavior described in KT-62918
#KT-62918 Obsolete
Related to: KT-60086, KT-59920
2023-10-26 19:41:13 +00:00
Alexander Korepanov 4ebfed04d3 [JS IR] Add tests for JS code KLIB diagnostics
^KT-62425
2023-10-26 19:22:14 +00:00
Alexander Korepanov 261527939b [JS IR] Fix JS code diagnostics tests according to new KLIB checks
^KT-62425
2023-10-26 19:22:14 +00:00
Alexander Korepanov 04809a6b3b [JS IR] Move tests for JS code diagnostics
^KT-62425
2023-10-26 19:22:14 +00:00
Alexander Korepanov 78aa34b3e8 [JS IR] Fix JS box tests
^KT-62425
2023-10-26 19:22:14 +00:00
Svyatoslav Kuzmich a8e5655ffe [Wasm] K2 port of definedExternally diagnostic (KT-56849) 2023-10-26 12:40:17 +00:00
Evgeniy.Zhelenskiy ce396f4ab6 [FIR] Add check inline declaration inside constructor calls
#KT-59933
2023-10-26 11:29:26 +00:00
Evgeniy.Zhelenskiy 6a5b356d30 [FIR] Add check of abstractness and existence of receiver parameters for lateinit var; add lacking lateinit modifier
#KT-59973
2023-10-26 11:08:27 +00:00
Anastasia.Nekrasova e789e08fb7 [K2] Disappeared FORBIDDEN_VARARG_PARAMETER_TYPE
^KT-59991
2023-10-26 10:51:48 +00:00
Vladimir Sukharev 604c8edd1c [K/N] Fix kt53261_* tests to be dummy in debug mode
^KT-62157 Fixed


Merge-request: KT-MR-12720
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-25 16:07:01 +00:00
Ilya Goncharov 065733e87c [FIR] Add UNINITIALIZED_ENUM_ENTRY on access qualifier of local enum
^KT-59967 fixed
2023-10-25 15:36:11 +00:00
Jinseong Jeon 1ccb085e68 SLC: use fully expanded type when computing nullability
^KT-62757 fixed
2023-10-25 14:59:50 +00:00
Alejandro Serrano Mena f227447837 [K2] Disallow named functions as expressions
^KT-62573 Fixed
^KT-59945 Fixed
2023-10-25 13:24:30 +00:00
Dmitrii Gridin 3941b05909 [FIR] do not transform annotations on delegated property accessors during implicit type phase
^KT-62874 Fixed
2023-10-25 08:59:15 +00:00
Dmitrii Gridin 1b636bf450 [FIR] add tests on annotations for delegated getter during implicit type phase
^KT-62874
2023-10-25 08:59:15 +00:00
Ivan Kochurkin d50c6f1b6d [FIR] Fix missing USELESS_CAST
`FirUselessTypeOperationCallChecker` always checks exact types matching for `as` operator

Simplify code of cast checker and utils

^KT-56629 Fixed
^KT-56615 Fixed
^KT-59820 Fixed
2023-10-24 20:59:56 +00:00
Dmitrii Gridin 2f8026f335 [LL FIR] add missed diagnostic tests for scripts
^KT-62840
^KT-62841
^KT-62861
2023-10-24 19:32:54 +00:00
Mikhail Glukhikh 3cb9396b20 K2: prefer derived class sources for callable copies (e.g. fake overrides) 2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 4b2a122f80 FIR2IR: make delegate field/accessors sources closer to PSI2IR
#KT-59864 Fixed
2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 47fec1a113 K2: use similar sources for if branches (PSI/LT)
Related to KT-59584
2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 21b4ce050c K2: add source range test to ensure #KT-59584 Fixed 2023-10-24 17:08:40 +00:00
Mikhail Glukhikh 920b0bfe63 FIR2IR: use SYNTHETIC_OFFSET for data class generated members 2023-10-24 17:08:40 +00:00
Mikhail Glukhikh a9894b1842 K2: use derived class sources for callable copies if base callables have no sources
Related to KT-60155
2023-10-24 17:08:40 +00:00
Vladimir Sukharev 8395018de8 [FIR] Fix disappeared INVALID_CHARACTERS_NATIVE_ERROR
https://youtrack.jetbrains.com/issue/KT-60003/K2-Disappeared-INVALIDCHARACTERSNATIVEERROR

^KT-60003 Fixed

Merge-request: KT-MR-12686
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-24 16:28:30 +00:00
Svyatoslav Kuzmich aeeb5d5c48 [Wasm] Disallow dynamic type in K2 (KT-56849) 2023-10-24 10:54:58 +00:00
Ivan Kochurkin bb937a8a21 [FIR] Initialize annotations in FirErrorTypeRef
^KT-62447 Fixed
^KT-62628 Fixed
2023-10-24 10:53:33 +00:00
Dmitrii Gridin ec3cfdefcb [LL FIR] add missing file node to control flow graph
The file

^KT-62834 Fixed
2023-10-24 10:30:55 +00:00
Dmitrii Gridin a1ee07603a [FIR] add cfg dump to script test
^KT-62834
2023-10-24 10:30:55 +00:00
Dmitrii Gridin 2eb761adae [LL FIR] generate resolution tests over codegen/box testData
Such testData can contain contract violations and other resolution
problems, so we should check them as well

^KT-62776
^KT-62832
^KT-62834
^KT-62836
2023-10-24 10:30:55 +00:00