Commit Graph

6777 Commits

Author SHA1 Message Date
Leonid Startsev 648c1f4599 Support instantiation of annotations with type parameters
By ignoring type parameters. Since type parameters in annotations are a
very limited feature, their sole use is to be able to specify them as
KClass argument: annotation class Foo<T: Any>(val bar: KClass<T>).
Since we can encounter type param only as a KClass type argument (and
never as a property type), simple approach of ignoring them works fine.
In that case, since we simply copy property types to synthetic
implementation class, its properties in IR start look like this:
annotation class FooImpl(override val bar: KClass<T of Foo>). This IR
seems to be not completely correct, since FooImpl.bar type contains T of
Foo param, which is out of its scope. However, so far I didn't
encounter any problems with this during testing and after MR discussion
this approach has been considered possible.

#KT-59558 Fixed
#KT-59036 Fixed
2023-07-26 17:16:13 +00:00
Mikhail Glukhikh 5836a8aa0b K2: add more tests/fix augmented assignment case around KT-59748 2023-07-26 06:09:15 +00:00
Mikhail Glukhikh f20e2dec31 K2: generate Unit conversion for indexed assignment at raw FIR stage
#KT-59748 Fixed
2023-07-26 06:09:15 +00:00
Mikhail Glukhikh 1832413a02 K2: reproduce KT-59748 2023-07-26 06:09:15 +00:00
Mikhail Glukhikh a428ab6ed6 K2: handle alias-based types nullability properly in ConeTypeContext
#KT-60154 Fixed
2023-07-26 06:02:42 +00:00
Nikita Bobko f4ba5aaf9a [FE 1.0] Prohibit implicit Java actualization in K1
^KT-58545 Fixed
Review: https://jetbrains.team/p/kt/reviews/10561

It's not yet supported in K2 KT-59213

Related tests:
- ApiTest.testStdlib
- RuntimePublicAPITest.kotlinStdlibRuntimeMerged
- KotlinProjectViewTestGenerated.test_Arrays (in Kotlin plugin)
2023-07-25 22:30:09 +02:00
Nikolay Lunyak 57908eba77 [FIR] Prevent replacing UNNECESSARY_SAFE_CALL with UNEXPECTED_SAFE_CALL
UNNECESSARY_SAFE_CALL is a warning,
UNEXPECTED_SAFE_CALL is an error, thus
it's a breaking change.

Also see KT-60695.

^KT-59860 Fixed


Merge-request: KT-MR-11210
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-07-25 13:16:37 +00:00
Kirill Rakhman 06d2befb72 [FIR] Implement DATA_CLASS_OVERRIDE_DEFAULT_VALUES diagnostic
#KT-59415 Fixed
2023-07-25 11:25:43 +00:00
Kirill Rakhman 53ff4584d4 [FIR] Implement DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE diagnostic
#KT-59409 Fixed
2023-07-25 11:25:43 +00:00
Dmitrii Gridin d93ffe0aec [FIR] add missing resolve for ConeFunctionExpectedError building
^KT-60638 Fixed
2023-07-25 10:55:41 +00:00
Pavel Kirpichenkov 9b82ff7a8d [LL] Don't filter out metadata declaration from stub symbol provider
Now the stub-based symbol provider is reused for common source sets,
which use metadata dependencies. Filtering should be done on scope
level, then declaration provider won't yield them in the first place.

KT-58769
2023-07-25 09:15:30 +00:00
Pavel Kirpichenkov 71b29f0cd7 [tests] Add a diagnostic test for function resolution in common module 2023-07-25 09:15:29 +00:00
Pavel Kirpichenkov b316aa7d1d [AA] stub-based library symbol providers for non-JVM platforms
Use existing stub-based JVM library symbol provider for .knm and
.kotlin_metadata files. The only real difference is the scope filtering
by file types

KT-58769
2023-07-25 09:15:29 +00:00
Kirill Rakhman 129b930bd7 [FIR] Implement NOT_SUPPORTED_INLINE_PARAMETER_IN_INLINE_PARAMETER_DEFAULT_VALUE diagnostic
#KT-59398 Fixed
2023-07-25 07:48:22 +00:00
Brian Norman 42ebbb937c [FIR] Recursively search dependsOn modules in visibility checks
#KT-59071 Fixed
2023-07-24 14:20:57 +00:00
Roman Efremov cedfdbdc66 Fix test became invalid after KT-59739
^KT-58551
2023-07-24 14:25:26 +02:00
Artem Kobzar 53aa8eddfe [K/JS] Generate unstable names on Frontend-checks for declarations with the JsExport.Ignore annotation ^KT-60202 Fixed 2023-07-24 09:52:58 +00:00
Roman Efremov 6611a55a60 [FE] Relax rules of matching @Target annotation on expect and actual
Allow `expect` targets to be subset of `actual`.

^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov ad84c83ee9 [FE] Skip more special annotations in KMP annotation matching
Many errors are reported in stdlib with these annotations
(SinceKotlin, Deprecated, so on).
But having them only on expect is a valid case. E.g. SinceKotlin added
if some old platform-specific API becomes commonized.

^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov 1dcdcee452 [FE] Add test for intrinsic const evaluation in KMP annotation matching
^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov 234f453173 [FE, IR] Don't check SOURCE annotations if actual declaration has no source
^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov 454756a2b5 [IR] Don't check annotations on expect/actual fake overrides
^KT-58551
2023-07-24 09:48:48 +00:00
Roman Efremov 2980179bd7 [IR] Implement IR checker for expect actual annotations matching
^KT-58551
2023-07-24 09:48:48 +00:00
Roman Efremov b6cae1adcc [FE] Allow @OptionalExpectation to be present only on expect
^KT-58551
2023-07-24 09:48:48 +00:00
Roman Efremov 1a4ab9bb4b [FE] Implement FE logic of expect actual annotations matching
This implementation only checks annotations set on expect/actual
declarations and requires further refinement (e.g. checking of other
annotation targets, class scopes within typealiases).

^KT-58551
2023-07-24 09:48:48 +00:00
Nikita Bobko 4f3ecedbca [FE] Stop ignoring ABSTRACT_MEMBER_NOT_IMPLEMENTED for expect classes
^KT-59739 Fixed
Review: https://jetbrains.team/p/kt/reviews/11038/timeline
2023-07-24 09:15:11 +00:00
Alexander Korepanov 89c3781c8e [JS FIR] Support NAME_CONTAINS_ILLEGAL_CHARS diagnostic
^KT-59392 Fixed
2023-07-21 13:54:34 +00:00
Alexander Korepanov 37c8ec1e51 [JS FIR] Support JS_BUILTIN_NAME_CLASH diagnostic
^KT-59391 Fixed
2023-07-21 13:54:34 +00:00
Dmitrii Gridin 8820867341 [FIR] support flexible types in ConeKotlinType#independentInstance
^KT-60580 Fixed
2023-07-20 17:22:56 +00:00
Nikolay Lunyak 84dd1acec1 [FIR] Check typealiases in supertypes
^KT-59830 Fixed

Merge-request: KT-MR-11187
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-07-20 12:50:06 +00:00
Ivan Kochurkin 8c39b2f71d [FIR] Report missing NO_ELSE_IN_WHEN for when statement with expect enums and sealed classes
^KT-59404 Fixed
2023-07-20 11:04:17 +00:00
Ivan Kochurkin d8ccf21894 [FIR] Fix false positive "suspension point is inside a critical section"
^KT-55072 Fixed
2023-07-20 10:38:59 +00:00
Ivan Kochurkin 43c66ee0e5 [FIR] Fix arguments mapping for indexed set operator
Now processPositionArgument changes STATE as well as processNamedArgument

^KT-59386
2023-07-20 09:38:28 +00:00
Ivan Kochurkin 8f5294a508 [FIR] Consider explicit returns during computing return type of anonymous function
Introduce FirAnonymousFunctionReturnExpressionInfo

^KT-59386
2023-07-20 09:36:55 +00:00
Kirill Rakhman 9288a96f6d [FIR] Assert source is not-null when reporting cone diagnostics
#KT-55835
#KT-59856
2023-07-20 07:29:18 +00:00
Kirill Rakhman 2f3293f99e [FIR] Skip redundant INAPPLICABLE_CANDIDATE on call with unresolved callable reference argument
A new resolution diagnostic UnsuccessfulCallableReferenceAtom is
introduced that is used in EagerResolveOfCallableReferences.
No diagnostic is reported on unresolved calls with this diagnostic
because

#KT-59856
2023-07-20 07:29:18 +00:00
Kirill Rakhman 97024d9ccb [FIR] Resolve array literal argument for non-primitive-array parameter as arrayOf call in annotation calls
This allows us to properly complete array literals arguments of
annotation calls fixing several false-negative type mismatch errors
as well as enabling the inference of generic type arguments.

#KT-59581 Fixed
#KT-58883 Fixed
2023-07-19 13:34:58 +00:00
Kirill Rakhman ff6b3350ae [FIR] Resolve array literal with non-primitive-array expected type as arrayOf call
This lets us properly complete the call which fixes some issues with
false-positive type mismatches.
This change doesn't apply to array literals in annotation calls yet
because they are resolved as context-dependent.
This will be adapted in a following commit.

#KT-59581
2023-07-19 13:34:58 +00:00
Dmitrii Gridin d0854d5b45 [FIR] propagate copy of original ConeKotlinType to anonymous functions to avoid concurrent modification
It is required to avoid leakage of annotations instance from
the original type
It should be enough to just create a new instance of an annotation
without a deep copy, because transformer shouldn't touch it

^KT-60387 Fixed
2023-07-19 11:50:12 +00:00
Dmitrii Gridin 4366164b65 [FIR] ConeAttributes: fix plus method
The 'plus' method was actually creating a new 'ConeAttributes' with
only one new attribute due to a typo inside 'buildList'

^KT-60451
^KT-60504
2023-07-19 10:40:03 +00:00
Ivan Kochurkin 5f1e2764c3 [FIR] Fix some missing EXPECTED_DECLARATION_WITH_BODY 2023-07-19 10:14:08 +00:00
Ivan Kochurkin 8f4a580c17 [FIR] Report EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL
^KT-59069 Fixed
2023-07-19 10:14:08 +00:00
Alexander Korepanov 08d158f901 [JS FIR] Support JS module system FE diagnostics
Support CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM diagnostic
^KT-59377 Fixed

Support CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM diagnostic
^KT-59381 Fixed

Support CALL_FROM_UMD_MUST_BE_JS_MODULE_AND_JS_NON_MODULE diagnostic
^KT-59417 Fixed
2023-07-18 14:02:30 +00:00
Alexander Korepanov 6034d32d7c [JS FIR] Support DYNAMIC_NOT_ALLOWED diagnostic
^KT-59384 Fixed
2023-07-18 14:02:30 +00:00
Alexander Korepanov 39fba56de9 [JS FIR] Support PROPERTY_DELEGATION_BY_DYNAMIC diagnostic
^KT-59406 Fixed
2023-07-18 14:02:30 +00:00
Alexander Korepanov f6b7a07efe [JS FIR] Support EXTERNAL_INTERFACE_AS_REIFIED_TYPE_ARGUMENT diagnostic
^KT-59416 Fixed
2023-07-18 14:02:30 +00:00
Alexander Udalov 8fc6c03e16 Tests: merge firTestWithJvmBackend into testsWithJvmBackend 2023-07-17 16:55:24 +00:00
Alexander Udalov 9935519656 Tests: add RENDER_ALL_DIAGNOSTICS_FULL_TEXT directive
Use it in diagnostic tests with JVM backend instead of the
RENDER_DIAGNOSTICS_FULL_TEXT directive.

This is needed because otherwise in
AbstractDiagnosticsTestWithJvmBackend there are two handlers trying to
dump full diagnostic texts: JvmBackendDiagnosticsHandler and
FirDiagnosticsHandler, which dump different diagnostics (reported by
backend vs frontend) and in slightly different formats.

In fact, this is why exceptionFromInterpreter.fir.diag.txt was added in
48484368c7: the existing .diag.txt was detected as incorrect by
FirDiagnosticsHandler (even though the diagnostics are the same, just
printed in a different way), which led to the creation of .fir.diag.txt.
For these tests, the behavior about checking diagnostic text in
FirDiagnosticsHandler is useless because it doesn't include backend
diagnostics. So we disable it by using another directive.
2023-07-17 16:55:24 +00:00
Alexander Udalov dd3bebb690 Remove obsolete directives in diagnostic backend tests 2023-07-17 16:55:24 +00:00
Alexander Udalov 6f2bb8c05a Rename tests with diagnostics on JVM backend
Remove the "_ir" suffix. It was originally used to distinguish tests on
the JVM IR backend from the old JVM backend ("_old"), but the latter are
removed now.
2023-07-17 16:55:24 +00:00