Commit Graph

43827 Commits

Author SHA1 Message Date
Toshiaki Kameyama 833edfb209 [IDE] EXPOSED_RECEIVER_TYPE: add quickfix to decrease visibility on the use side
^KTIJ-23267 Fixed
2023-05-23 12:33:31 +00:00
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
Alexander Korepanov 6f7fc14695 [JS IR] Enable all K2 klib IC tests 2023-05-23 10:13:26 +00:00
Alexander Korepanov 1fb8293968 [JS IR] Change default declaration origin for IC symbols 2023-05-23 10:13:26 +00:00
Alexander Korepanov e4d7897071 [JS IR] Check fir compilation errors after checking IC next round 2023-05-23 10:13:26 +00:00
Alexander Korepanov 28b781f60a [JS IR] Move fir to klib serialization code in separate class 2023-05-23 10:13:26 +00: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
Denis.Zharkov 6b2da2069d K2: Use Any? expected type only for the right argument of == operator
^KT-47409 Fixed
2023-05-22 08:41:55 +00:00
Igor Yakovlev 1749bafc30 [Wasm] Rename dateref to structref 2023-05-19 15:50:07 +00:00
Igor Yakovlev 1e0be4e0af [Wasm] Fix null constant typed with external class upperbound 2023-05-19 15:50:06 +00:00
Igor Yakovlev 6adfd91169 Revert "[Wasm] Revert a7ed496a and few fixes to make Kotlin/Wasm compatible with Firefox"
This reverts commit 1d793f7bec.
2023-05-19 15:50:06 +00:00
Igor Yakovlev 6437d0919c [Wasm] Replace deprecated cast instructions 2023-05-19 15:50:06 +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
Anastasia.Nekrasova 58fca659a2 [IR] Fix private methods with default parameters
It is required for methods with default parameters to pass a dispatchReceiver (if the IrCall has one) as an argument, because the method generated bytecode expects it. In the case where the function has both receivers (dispatchReceiver and extensionReceiver), only the extensionReceiver should be added.

Related to KTIJ-24564
2023-05-19 13:56:21 +00:00
Dmitrii Gridin 579df97a7c [FIR] errorInLazyResolve: fix typo 2023-05-19 15:30:32 +02:00
Alexander Udalov fb900d2e2a JVM: remove most usages of JvmTarget.JVM_1_6 2023-05-19 13:24:00 +00:00
Alexander Udalov 75197d1b86 JVM: remove diagnostics related to JVM target 1.6 2023-05-19 13:24:00 +00:00
Alexander Udalov e4e1bcefbd JVM: remove tests on JVM target 1.6 2023-05-19 13:23:59 +00:00
Dmitrii Gridin 2885df14ee [LL FIR] rewrite status phase transformer
Now we will try to avoid redundant calculation:
* Class-like declarations can be calculated without super types
* Overridden search logic not is out of lock

Unfortunately, right now it is not safe to use
StatusResolveMode.FunctionWithSpecificName and
StatusResolveMode.PropertyWithSpecificName
because lazyResolveToPhaseWithCallableMembers can lead to an incorrect
state of scope. Example:
```
open class A {
  open fun a() {}
  open fun b() {}
}
class C : A()
```
Steps:
1. Resolve constructor of C to STATUS
2. Now we want to call lazyResolveToPhaseWithCallableMembers on
C, and this call will do nothing because this class and all
its declarations (only constructor) are already in STATUS phase,
so class A won't be resolved as expected

^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin e464af00db [LL FIR] do not calculate constructors with classes during types phase
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin 5b3f617378 [FIR] add memberRequiredPhase to declaredMemberScope
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin 04231d7497 [AA FIR] add missing memberRequiredPhase to some usages of unsubstitutedScope
^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin fdec0bd942 [FIR] drop redundant memberRequiredPhase parameter from overriddenFunctions
It should be STATUS always, because we want to process overrides

^KT-56551
2023-05-19 12:43:45 +00:00
Dmitrii Gridin aaf173687b [FIR] rename requiredPhase to requiredMembersPhase for type scope
Also move `requiredMembersPhase` use inside `unsubstitutedScope`

^KT-56551
2023-05-19 12:43:44 +00:00
Dmitrii Gridin 52ce302095 [FIR] AbstractFirStatusResolveTransformer: drop unreachable 'if'
^KT-56551
2023-05-19 12:43:44 +00:00
Dmitrii Gridin 71386cc117 [FIR] SignatureEnhancement: fix CME from type parameters enhancement
The problem was that type parameters of Java function were changed
without any synchronization.
In fact, we shouldn't mutate Java declarations at all.
So now we don't mutate type parameters – instead of this,
we mutate only its copy that is safe

^KT-58613 Fixed
^KTIJ-25242 Fixed
^KTIJ-21791 Fixed
2023-05-19 12:17:12 +00:00
Anastasia.Nekrasova fa6fc0e334 [IR] Fix local function with default param
The key 'localDeclarationsData' is a IrFunction whose symbol owner is 'IrDeclarationOrigin.LOCAL_FUNCTION'. To find the 'localsData', it's required to get the original local IrFunction ('IrDeclarationOrigin.LOCAL_FUNCTION') for the IrFunction with default arguments (IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER).

Related to KTIJ-25558
2023-05-19 11:57:10 +00:00
Kirill Rakhman aacdfb67c6 [Stubs] Bump stubs version
#KT-58786
2023-05-19 11:50:40 +00:00
Kirill Rakhman 47b8fd7e0c [AA] Mute tests related to decompilation of aliased types from stubs
#KT-58786
2023-05-19 11:50:40 +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
Dmitriy Novozhilov 8338370fbd [FE 1.0] Provide implementation of ExpectActualMatchingContext for FE 1.0
^KT-58578
2023-05-19 10:19:17 +00:00
Dmitriy Novozhilov b26b649d4e [FE] Introduce commonized version of expect/actual compatibility calculator
This is needed to use the same code for those checks between
  both frontends and backend

^KT-58578
2023-05-19 10:19:17 +00:00