Commit Graph

46232 Commits

Author SHA1 Message Date
Pavel Kirpichenkov 30d45039fb [decompiler] Fix property and receiver annotations loading for stubs
Add annotation loading for property backing field, property delegate and
extension receiver to AnnotationLoaderForStubBuilderImpl. Use logic from
AnnotationAndConstantLoaderImpl.

AnnotationLoaderForStubBuilderImpl is used by KotlinMetadataDecompiler,
K2KlibMetadataDecompiler and KotlinJavaScriptMetaFileDecompiler. Stub
versions for built-ins (affects metadata and K/N decompilers) and JS
are bumped.

KTIJ-26761
KTIJ-26961
2023-11-02 10:28:37 +00:00
Kirill Rakhman 0682a1f76d [FIR] Remove line breaks after context receivers in diagnostic messages
#KT-62944 Fixed
2023-11-02 08:58:28 +00:00
Nikita Bobko 173651eb5c Fix misconfigured widerVisibilityInActualClassifier test
^KT-59977 Fixed
Review: https://jetbrains.team/p/kt/reviews/12807/timeline
2023-11-01 19:14:20 +00:00
Dmitriy Novozhilov e473b52da7 [Test] Add additional test for KT-21463 2023-11-01 17:39:33 +00:00
Ivan Kylchik 32057f6d10 [JVM_IR] Use createSimpleNamedCompilerPhase to create lowerings 2023-11-01 14:01:17 +00:00
Ivan Kylchik f5bb477459 [JVM_IR] Move all stickyPostconditions into single lowering
`stickyPostconditions` are such conditions that are checked
every time after applying when a new lowering finishes its execution.
Right now we are using them only in JVM, and this is a blocker
for adopting Native approach for lowering execution.

In Native we are using
`SimpleNamedCompilerPhase<in Context : LoggingContext, Input, Output>`
as the common super type for all lowerings. Here we have `Input` and
`Output` that can potentially be different and `stickyPostconditions`
don't have much sense in that case.
2023-11-01 14:01:17 +00:00
Ivan Kylchik 6a02a26db8 [Native] Move createSimpleNamedCompilerPhase into common.phaser.PhaseBuilders
This is needed to be able to reuse these functions
for other backends.
2023-11-01 14:01:17 +00:00
Ivan Kylchik 465fc9116e [IR] Drop some old lower utils that are not used anymore 2023-11-01 14:01:17 +00:00
Dave MacLachlan 722ddc9f91 Use fileKey instead of canonicalPath when deduping files
`resolveDependencies` showed up as a hotspot when profiling due to `canonicalPath` doing a lot of file system calls.
`fileKey` is more efficient and should guarantee uniqueness (`canonicalPath` may fail in the case of hardlinks).
The new code is 3x faster in our use case.
2023-11-01 13:59:13 +00:00
Ilya Goncharov 3673dff959 [FIR] Only one specific diagnostic for data class without parameters left
^KT-60042 fixed
2023-11-01 13:58:44 +00:00
Brian Norman e9983a947f [FIR] Add checker for EXPANSIVE_INHERITANCE
^KT-59402 Fixed
2023-11-01 13:53:57 +00:00
Mikhail Glukhikh d6cefb363b K1/K2: add test to confirm KT-61100 behavior 2023-10-31 22:13:10 +00:00
Mikhail Glukhikh af58b30e5f K2 Java: fix 'value' annotation constructor parameter type to Array<out>
#KT-61100 Fixed
2023-10-31 22:13:10 +00:00
Vladimir Sukharev 8e4a6759a4 [FIR] Fix Disappeared INVALID_CHARACTERS
^KT-59996 Fixed
2023-10-31 22:04:06 +00:00
Kirill Rakhman ac203591e5 [FE, Java resolve] Support inheritors of sealed Java type without permits clause
This fixes a false negative NO_ELSE_IN_WHEN in K2 and incidentally
also fixes a false positive NO_ELSE_IN_WHEN in K1 since the fix is in
the common code.

#KT-62491 Fixed
2023-10-31 13:41:56 +00:00
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
Alexander Udalov 6a1c210cd1 Minor, remove obsolete mention of issue in previously muted test
The test was fixed for K2 in 365ce2a6a5.
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
Alexander Korepanov ec71fe20e2 [JS IR] Fix file name clashes during JS BE invalidation 2023-10-30 09:14:16 +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 d694c5d219 [FIR] Add references to the related K1 functions 2023-10-30 06:58:40 +00:00
Nikolay Lunyak cb4183bec6 [FIR] Remove enforcesEmptyIntersection
It's confusing + it's not really
correct. It checks properties of
LUB types rather than the original
ones, but if we want to replicate
K1, we should check the originals.
2023-10-30 06:58:40 +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 3fb7407ca1 [FIR] Make FirEqualityCompatibilityChecker a bit more readable 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 87563f3aea [FIR] Rename diagnostic renderers that insert quotes and fix some messages
#KT-62386
2023-10-27 13:27:35 +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 ef78d4b95a [FIR] Fix deserialization of generic context receivers
We need to pass the local deserialization context so that generic
type parameters can be referenced.

#KT-62607 Fixed
2023-10-27 11:35:22 +00:00
Dmitriy Dolovov f276fe6506 [KLIB] Add a reliable mechanism to check if KLIB has IR inside
^KT-62341
2023-10-27 09:27:59 +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
Ilya Kirillov a90562c0da [Analysis API] support creating KtSymbol by K/JS dynamic scope
^KT-61257 fixed
2023-10-26 19:28:27 +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