Commit Graph

17351 Commits

Author SHA1 Message Date
Nikita Bobko 088c25ea41 [Test] Refactor DeferredInit testData to make it more readable
Review: https://jetbrains.team/p/kt/reviews/9967

1. Fix weird indentation in ValDeferredInit*
2. Use meaningful names in ValDeferredInit*
3. Drop leading indentation in VarDeferredInit*. Not everyone has a wide
   monitor
4. Add some NOTICABLE comment that VarDeferredInit* test should be read
   as table
2023-05-23 14:12:29 +03:00
Nikita Bobko 771f82bcf6 [FE] Fix "Not reachable case" exception
Review: https://jetbrains.team/p/kt/reviews/9967

This commit fixes:

    Cause 2: java.lang.IllegalStateException: Not reachable case. We can always suggest making `open val` property `final`
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.reportMustBeInitialized(DeclarationsChecker.kt:845)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.checkPropertyInitializer(DeclarationsChecker.kt:778)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.checkProperty(DeclarationsChecker.kt:614)
            at org.jetbrains.kotlin.resolve.DeclarationsChecker.process(DeclarationsChecker.kt:106)
            at org.jetbrains.kotlin.resolve.BodyResolver.resolveBodies(BodyResolver.java:258)

Reproducible in K1 & K2
2023-05-23 14:12:29 +03:00
Nikita Bobko 26e45304e1 [Test] backingField testData: migrate from deprecated directive syntax
Review: https://jetbrains.team/p/kt/reviews/9967
2023-05-23 14:12:29 +03:00
Nikita Bobko de8c3826c2 [FE] Prohibit missed MUST_BE_INITIALIZED when there is no primary constructor
^KT-58472 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967
2023-05-23 14:12:29 +03:00
Nikita Bobko ac40010501 [FE] Prohibit open val deferred initialization
^KT-57553 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967

Other related tests:
- testUninitializedOrReassignedVariables
- testUseOfPropertiesWithoutPrimary
- @TestMetadata("compiler/testData/diagnostics/tests/secondaryConstructors")
- testAugmentedAssignmentInInitializer
- testInitOpenSetter
- testInitOverrideInConstructorComplex
- testPropertyInitializationOrder
2023-05-23 14:12:28 +03:00
Nikita Bobko 38319c55a8 [FE] Replace some MUST_BE_INITIALIZED messages with MUST_BE_INITIALIZED_OR_BE_FINAL
From user point of view it's an improvement in compilation message.

From technical point of view it's an introduction of new compilation
diagnostic.

Review: https://jetbrains.team/p/kt/reviews/9967

I'm going to deprecate `open val` case in the next few commits KT-57553.
But it is always possible to suggest using `final` for `open val` case.
2023-05-23 14:12:28 +03:00
Nikita Bobko d9d4dee582 [FIR] fix false negative MUST_BE_INITIALIZED for deferred init + custom setter case
^KT-58346 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967

BTW this commit accidentaly and partially fixes KT-57553 for K2, because
of a cleaner K2 architecture. I will unify MUST_BE_INITIALIZED behaviour
in K1 and K2 in the next commits
2023-05-23 14:12:28 +03:00
Nikita Bobko 151144bbed [Test] Cover properties deferred initialization with more tests
Review: https://jetbrains.team/p/kt/reviews/9967

I'm going to change the logic in this area in the next few commits
KT-57553. So let's cover the current behaviour with tests.

*.fir.kt tests are not properly formatted because of K1 and K2 different
behaviour. I will fix it in the next commits
2023-05-23 14:12:28 +03:00
Sergej Jaskiewicz 1a29b9efff [FIR, IR] Fix name mangling for functions with context receivers
- Mangled names of property accessors now include context receiver
  types of the corresponding property when computed from FIR.
- Context receivers are now supported when computing mangled names
  from IR
- IrBasedDescriptors now account for context receivers

^KT-57435 Fixed
2023-05-23 08:55:50 +00:00
Alexander Udalov 83865782ff FIR: do not generate annotations on properties from delegation
#KT-57228 Fixed
2023-05-22 20:12:29 +00:00
Alexander Udalov 40c628d431 FIR: fix order of property accessor annotations
#KT-57219 Fixed
2023-05-22 20:12:29 +00:00
Alexander Udalov 9c995755f0 Remove obsolete backend test on getter-targeted annotations
`@get:... get` is no longer allowed, see the explanation in KT-15470.
2023-05-22 20:12:29 +00:00
Kirill Rakhman 7a9c516f68 [FIR] Use Throwable as expected type for throw expressions
#KT-58533 Fixed
2023-05-22 14:05:28 +00:00
Nikolay Lunyak 710a8f4e0f [FIR] KT-58719: Check all imported declarations for visibility
Unfortunately, we have to check
callables even if the class is
inaccessible.

^KT-58719 Fixed
2023-05-22 11:40:30 +00:00
Nikolay Lunyak f446fc4154 [FIR] KT-58719: Ensure the compiler resolves to the class 2023-05-22 11:40:30 +00:00
Denis.Zharkov 67d51eb7ee Add a separate test configurations for JDK 21 dependent test
After it's released, there would be no need in them, but right now
they are unavailable through the toolchain, so we can't require it.
See KT-58765 for tracking

But there should be a dedicated Build configuration with JDK_21_0 env
properly set.

^KT-58716 Fixed
2023-05-22 09:19:52 +00:00
Igor Yakovlev 1749bafc30 [Wasm] Rename dateref to structref 2023-05-19 15:50:07 +00:00
Kirill Rakhman df03f0df0a [FIR] Implement deprecation for implementing var by inherited val
#KT-56779 Fixed
2023-05-19 15:04:46 +00:00
Mikhail Glukhikh 941446ea39 FE: rework tests around changed progression resolve
Related to KT-54261, KT-36932, KT-49276
2023-05-19 14:57:26 +00:00
Mikhail Glukhikh 5fda57fa55 FE: delay DisableCheckingChangedProgressionsResolve to 2.*
This commit removes the relevant feature from 1.9 and
makes this feature experimental.
We plan to enable it in some 2.* version (not earlier than 2.1)

Related to KT-54261, KT-36932, KT-49276
#KT-58791 Fixed
2023-05-19 14:57:26 +00:00
Alexander Udalov e4e1bcefbd JVM: remove tests on JVM target 1.6 2023-05-19 13:23:59 +00:00
Sergey Bogolepov c57c34525f [K/N] KT-58562: Implement frontend checkers for HiddenFromObjC on classes 2023-05-19 11:33:17 +00:00
Ilmir Usmanov f3a22e0ac4 Warn about suspend extension functional types as supertypes
They will become error in 2.0

 #KT-58529 Fixed
 #KT-49175 Fixed
2023-05-19 12:41:37 +02:00
Dmitriy Novozhilov b19116d3af [FIR] Provide implementation of ExpectActualMatchingContext for FIR
^KT-58578
2023-05-19 10:19:17 +00:00
Ivan Kylchik e0e1d57120 [IR] Check object init was called in case of name interpretation
#KT-58717 Fixed
2023-05-18 18:16:54 +00:00
Ivan Kylchik 70560fc3eb [IR] Handle each interpreter checker one by one
This wy we can interpret all expressions like `A::a.name` at first and
after that evaluate all complex expressions like
`A::a.name + A::b.name`.
2023-05-18 18:16:54 +00:00
Ivan Kylchik e58e20fc7b [IR] Add special preprocessors for ir interpreter
These preprocessors allow us to modify IR at first and only after that
try to evaluate. With this we can drop `KCallableNamePropertyLowering`.
2023-05-18 18:16:54 +00:00
Ivan Kylchik 1fd8ef801e [IR] Create special checker that will analyze name methods
We can insert all this logic into `IrCompileTimeChecker` but it is
a little bit specific and looks like it is nicer to just extract it.
2023-05-18 18:16:54 +00:00
Ivan Kylchik 535806d0ab [K2] Force interpretation of default argument for annotation's property
We miss these expression because they might be represented as
`IrGetFiled` values, but they still must be turned into `IrConst`.

#KT-58007 Fixed
2023-05-18 18:16:53 +00:00
Nikolay Lunyak f94c795b5b [FIR] KT-55552: Report type mismatch for delegated properties
^KT-55552 Fixed
2023-05-17 12:44:52 +00:00
Nikolay Lunyak 81d955a712 [FIR] KT-55552: Ensure type mismatch is missing 2023-05-17 12:44:52 +00:00
Sergej Jaskiewicz 56f977f70c [IR] Don't render facade classes in JVM fq-names in irText tests
This makes the tests more compatible with non-JVM backends
(see KT-58605)
2023-05-17 12:43:35 +00:00
Simon Ogorodnik 3e6b42083b FIR: Fix leakage of type variables in builder inference for lambdas returning Unit
When BI/incomplete call is present in return argument, it will be
added to the main call-tree, leading to requirement violation in
`ConstraintSystemCompleter.getOrderedAllTypeVariables`
as after `FirBuilderInferenceSession.inferPostponedVariables` it will
be completed, and its type variables couldn't be found anymore

In K1, we actually do the same, but we are able to find type variables
of such calls due to architecture difference:
In K2, `getOrderedAllTypeVariables` uses FIR as the main source to
lookup
In K1, `getOrderedAllTypeVariables` uses resolution atom tree, where
candidate/CS of the call is still available after
`inferPostponedVariables`

In fact, all incomplete calls were analyzed in FULL mode according to
the contract of `FirBuilderInferenceSession.addPartiallyResolvedCall`.
Thus, it means we normally shouldn't add them to the main call-tree, but
accidentally do it as incomplete calls contain non-completed candidate

This particular commit addresses the problem partially, only
in cases when the expected return type for the lambda is Unit and when
the incomplete call is located in the last expression of the lambda

In such cases, we can skip the call from the last expression completely,
since all potential calls there were analyzed in FULL mode,
and couldn't introduce any useful info to the CS of the main call-tree

^KT-54294
2023-05-17 10:50:36 +00:00
Dmitrii Gridin ae1622d059 [LL FIR] support lazy resolve for fake override declarations
^KT-58727 Fixed
2023-05-17 09:51:21 +00:00
Dmitrii Gridin 4472e1ae4e [AA FIR] add tests on implicit type in delegated scope
^KT-58727
2023-05-17 09:51:21 +00:00
Sergej Jaskiewicz 973adb6a38 [test] Remove TARGET_BACKEND: JVM_IR for non JVM-specific irText tests
If they fail on other backends, use the IGNORE_BACKEND directive instead
2023-05-16 18:28:23 +00:00
Nikolay Lunyak d72a50b3f5 [FIR] KT-58065: Support LT in K2JsIrCompiler 2023-05-16 12:11:46 +00:00
Nikolay Lunyak fd54706e1a [FIR] KT-58674: Set expected type for loop conditions
^KT-58674 Fixed
2023-05-16 10:40:25 +00:00
Nikolay Lunyak 737c8c20f6 [FIR] KT-58674: Ensure loop conditions have no expected type in K2 2023-05-16 10:40:25 +00:00
Kirill Rakhman 80d68fc908 [FIR] Deserialize reference to typealias from metadata as fully expanded
#KT-58335 Fixed
2023-05-16 09:20:57 +00:00
Vladimir Sukharev bbe1e708f9 [K2/N] Rewrite mpp tests from old native infra to new
^KT-58543

Merge-request: KT-MR-10065
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-05-16 08:41:39 +00:00
Dmitriy Dolovov 706a4e9919 [PL] Fix: Remove annotations containing unlinked arguments
Both explicitly specified and default argument expressions are considered.

In case an argument expression is considered as 'unlinked' the whole annotation
is removed from the declaration. An appropriate compiler warning logged for each
such case.
2023-05-16 08:30:29 +00:00
Sergej Jaskiewicz 6e8283a6fe [IR] Dump IdSignatures and mangled names in irText tests
The reason #1 for this feature is that we want to test IdSignatures
generated for declarations. Currently, there is no (easy) way to ensure
that a change in the signature building logic doesn't cause any breaking
changes wrt klibs.

Now, most IdSignatures include hashed mangled names in them, so even if
we catch a regression where the included hash changes, there would be no
way of knowing immediately what caused it, unless we'd also have mangled
names in the expectations.

The reason #2 is to test the manglers themselves. Currently, there are
no tests for them. They heavily duplicate each other, this is already
causing issues (see KT-57427) that would be very hard to catch without
these tests.

^KT-58238 Fixed
2023-05-15 18:20:45 +00:00
Sergej Jaskiewicz 1a8d5056bf [test] Mute an irText test on JS_IR instead of making it JVM-only
The test is not in any way JVM-specific, but it fails on the JS BE
because of different fq-names of stdlib symbols on JVM and JS.

The fix is in progress. Mute the test until the fix is ready.
2023-05-15 15:40:25 +00:00
Nikolay Lunyak 200fb1e5ce [FIR] KT-54874: Ensure this code is red
^KT-54874 Fixed
2023-05-15 14:44:10 +00:00
Denis.Zharkov c3ac2e44a0 Adjust test data for enabling ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
^KT-55388 Fixed
2023-05-15 10:43:19 +00:00
Nikolay Lunyak 7b45f75213 [FIR] KT-58523: Check the companion presence when resolving type-aliases
The change in `QualifiedNameResolution.kt` is
backed by `starImportOnTypeAlias.fir.kt` and
`javaStaticMembersViaTypeAlias.fir.kt`.
Note that referencing inner classes via type-aliases is
prohibited, but referencing enum entries is not.

^KT-58523 Fixed
2023-05-15 10:03:19 +00:00
Nikolay Lunyak 99ff36c77a [FIR] KT-58523: Ensure the compiler resolves to the typealias 2023-05-15 10:03:18 +00:00
Ivan Kylchik 3d4f3d2f57 [IR] Visit file annotations in IR interpreter
#KT-55866 Fixed
2023-05-15 08:32:37 +00:00
Mikhail Glukhikh 1ba900be44 FIR2IR: change origin & operator flag in data classes making them closer to K1
Related to KT-54887
2023-05-15 08:16:24 +00:00