Commit Graph

440 Commits

Author SHA1 Message Date
Kirill Rakhman 69a7bf7f68 [FIR] Add equality constraint from expected type for some synthetic function calls
This fixes some cases where we infer some type variable inside one
of the branches to Nothing instead of the expected type because Nothing
appeared in some other branch.

Specifically, we add an equality instead of a subtype constraint during
completion of calls to synthetic functions for if/when, try and !!.
We don't do it when the call contains a (possibly nested) elvis or is
inside the RHS of an assignment.
Otherwise, we would prevent some smart-casts.

#KT-65882 Fixed
2024-03-05 17:38:59 +00:00
Artem Kobzar 8d4948c3ee [K/Wasm] Generate .d.ts tests for K/Wasm in the same way as we do for K/JS ^KT-65778 Fixed 2024-03-05 15:33:56 +00:00
Pavel Kunyavskiy 8d725753f8 [Fir2IR] Don't build overrides for expect classes.
We don't need them except for checking.
And checking doesn't work in any reasonable way anyway.

^KT-65249 Fixed
2024-03-04 14:12:48 +00:00
Pavel Kunyavskiy 807d352ed4 [Tests] Add test for already fixed KT-60847
^KT-60847 Fixed
2024-03-01 12:51:21 +00:00
Artem Kobzar 2e4d02e9f4 [PSI2IR, K/Wasm] Sync start and end offsets on PSI and FIR for primary constructors 2024-02-29 14:42:33 +00:00
Igor Yakovlev a5ef668e3c [Wasm] Boolean boxed instances are the same
Fixed #KT-65411
2024-02-28 15:23:21 +00:00
Dmitriy Novozhilov 5c632bc78e [FIR2IR] Don't create f/o symbols on smartcasted Nothing in dispatch receiver
^KT-63525 Fixed
2024-02-28 08:28:14 +00:00
Marco Pennekamp 708ed81eb2 [Test] Avoid importing unused @Nested annotations in generated tests
- Unused `Nested` imports frequently cause unused import warnings in the
  IDE, which are especially annoying in after-commit warning/error
  analysis.
2024-02-27 20:30:06 +00:00
Artem Kobzar 3429cbd321 [K/JS] Support companion objects in external and exported declarations 2024-02-27 16:30:13 +00:00
Dmitriy Dolovov f204293e4d [Test] Unify work with KLIB artifact paths and dependencies
Unify functions from `JsEnvironmentConfigurator` and
`WasmEnvironmentConfigurator` that do the same logic. Make this logic
also be available for `NativeEnvironmentConfigurator`:
- get*ArtifactSimpleName()
- get*KlibArtifactPath()
- get*KlibOutputDir()
- getAllRecursiveLibrariesFor()
- getAllRecursiveDependenciesFor()
- getAllDependenciesMappingFor()
- getKlibDependencies()

This would allow to have the same logic in one place, and also
reuse it in `IrBackendFacade`s to be implemented for Native.

^KT-65117
2024-02-27 15:22:47 +00:00
Mikhail Glukhikh 678816f9e8 K1: introduce BUILDER_INFERENCE_STUB_PARAMETER_TYPE to prevent compiler crashes
This diagnostic is reported in rare situations when
StubTypeForBuilderInference is kept as a parameter type
of for loop or lambda. Before this commit, we had in K1
"Could not load module <error module>" from IrLinker instead.

Related to: KT-52757, KT-53109, KT-63841, KT-64066
#KT-53478 Fixed
2024-02-27 10:25:13 +00:00
Vladimir Sukharev febac0dd5f [Tests] Migrate backend-independent tests from native to compiler/testData.
^KT-65979
2024-02-26 13:38:49 +00:00
Dmitriy Novozhilov 9857bdc891 [FIR2IR] Unwrap typealiases during applying of suspend conversion
^KT-65002 Fixed
2024-02-26 08:56:24 +00:00
Nikita Nazarov 407448d8e3 [JVM] Implement new inlined variable naming format
^KT-65478 fixed
2024-02-23 23:59:13 +01:00
Yahor Berdnikau 6b19b8b9d0 [Repo] Don't use kotlinOptions in repo build scripts
^KT-63419 In Progress
2024-02-22 14:48:10 +00:00
Kirill Rakhman 634f0c2ae7 [FIR2IR] Unwrap named arguments for suspend conversion
#KT-65878 Fixed
2024-02-20 12:52:08 +00:00
Dmitriy Novozhilov 3469e3b198 [FIR2IR] Create delegated field for delegation to var property
^KT-65920 Fixed
2024-02-20 09:46:17 +00:00
Ilya Goncharov abb5f55087 [Wasm] Use static import for wasm imports
^KT-65777 fixed
2024-02-19 10:01:10 +00:00
Dmitriy Novozhilov acf2296590 [Test] Regenerate tests after two previous commits 2024-02-16 12:48:24 +00:00
Dmitriy Novozhilov 84f0f6e099 [FIR] Resolve statuses of supertypes for all non-source classes
Previously we forced computation only for java and precompiled classes,
  assuming, that binary class can not extend source class, but it's not
  true in two cases:
1. Classpath substitution: class with same name declared in library and
   the source (more rare case)
2. Metadata compilation: depends-on dependcies are passed in binary
   format, so `expect class` may be a binary one and corresponding
   `actual class` may be a source. So if some class in `common` module
   extend this expect class, actual class will be substituted instead of it

^KT-65669 Fixed
2024-02-15 12:18:48 +00:00
Vladimir Sukharev bf0150108d [K/N][Tests] Move filecheck and cinterop tests to /native/
^KT-61259
2024-02-14 23:36:34 +00:00
Igor Yakovlev be6b9e8a9a [Wasm] Support lazy associated object initialisation
Fix #KT-63939
2024-02-08 14:15:17 +00:00
Brian Norman c8e77aad91 [FIR] Fix CFG/DFA for delegate properties within PCLA
^KT-65262 Fixed
2024-02-07 22:34:12 +00:00
Vladimir Sukharev 112473f310 [Tests] Add test for KT-65197
^KT-65197
2024-02-07 09:03:49 +00:00
Igor Yakovlev ff20ae34e5 [Wasm/WASI] Allow external declarations only for top-level functions
Fix #KT-63737
2024-02-06 12:03:08 +00:00
Pavel Kunyavskiy caa6918031 [FIR2IR] Fix handling private setters in anonymous classes
^KT-65290 Fixed
2024-02-02 16:07:35 +00:00
Denis.Zharkov 66d8f471d9 K2: Fix internal error in FIR2IR caused by PCLA + String interpolation
There's an implicit contract in PCLA that the statement-level call
should be postponed iff it has something to be postponed inside.

And that contract didn't work well for string interpolation containing
some postponed calls.

Thus, we haven't run a completion results writing for them properly,
thus leaving type parameters (K from synthetic call) for expression
types instead of an inferred substituted type.

In this commit, the contract was reversed to explicitly enumerate
the cases when it's safe to resolve the candidate outside PCLA session.

See the comments at `mightBeAnalyzedAndCompletedIndependently`.

^KT-65341 Fixed
2024-02-02 15:40:47 +00:00
Alexander Udalov d450e3074b IR: do not build fake overrides for static members of interfaces
Split members into static/non-static, and only build fake overrides for
inherited static members of classes.

 #KT-65276 Fixed
 #KT-65277 Fixed
2024-02-01 23:25:50 +00:00
Brian Norman dde2156f5f [FIR2IR] Always use property type if var
For destructing calls, the component type is used for the property type
in all cases. However, this can result in runtime and/or compilation
errors when the property is a var and changed, especially when the
component is a primitive but the property type is nullable. Instead,
only use the component type when the property is also a val.

^KT-64944 Fixed
2024-01-31 22:27:18 +00:00
Kirill Rakhman 853ad54699 [FIR] Fix incorrect updating of callable reference type in delegated property
... if the delegate happens to be a function call whose second
argument is a callable reference but not actually a provideDelegate
call.
The fix is to ensure that the call is _actually_ a desugared
provideDelegate call.

This fixes a CCE in a case where the delegate expression is a regular
function call and the second argument is a callable reference.

#KT-65165 Fixed
2024-01-31 14:51:51 +00:00
vladislav.grechko 8b1d87848d [FIR2IR] Fix unwrapping of single-statement blocks
Unwrapping should be done with respect to `forceUnitType` parameter.

^KT-65019: Fixed
2024-01-30 14:26:10 +00:00
Sergej Jaskiewicz f39335b3f7 [klib] Don't pass around metadata serialization closure
Pass the metadata serializer instance instead. This allows to further
reduce code duplication by introducing the common interface
`KlibSingleFileMetadataSerializer` for abstracting away K1 and K2
representation of a source file, as well as reusing
`Fir2KlibMetadataSerializer` across different backends.

KT-64392
2024-01-29 21:07:43 +00:00
Sergej Jaskiewicz c335cd0b1e [IR] Remove unused IrMessageLogger from serialization logic 2024-01-29 21:07:43 +00:00
Artem Kobzar 1fe77705b0 [K/Wasm] Convert non-capturing lambdas into singletons ^KT-64803 Fixed 2024-01-29 12:52:18 +00:00
vladislav.grechko f318b5969d Erase non-reified type parameters by-default when inlining.
Substitution of type arguments to non-reified type parameters may lead
to accidental reification, which should not be done (see ^KT-60174 for
examples). So, we should erase them, except the few cases.

^KT-60174: Fixed
^KT-60175: Fixed
2024-01-26 18:31:20 +00:00
Denis.Zharkov ca80ddb8ca K2: Run completion-writer related PCLA tasks for irregular call kinds
- For synthetic calls
- For delegated constructor calls

Also, I checked that for each toResolvedReference() (beside annotations)
that converts candidate to the resolved reference,
we run `runPCLARelatedTasksForCandidate()` in the same context.

^KT-65103 Fixed
2024-01-26 18:13:27 +00:00
Artem Kobzar a593936b8a [K/Wasm] Fix stepping tests flakiness with reading stdout until it is empty 2024-01-26 16:20:41 +00:00
Anastasiia Spaseeva 945f602b91 Revert "[Wasm] Support lazy associated object initialisation"
This reverts commit 552ee1ee38.
2024-01-25 14:11:56 +01:00
Igor Yakovlev 552ee1ee38 [Wasm] Support lazy associated object initialisation
Fix #KT-63939
2024-01-24 16:24:44 +00:00
Igor Yakovlev 6b83eb282b [Wasm] Regenerate wasm tests 2024-01-24 15:41:38 +00:00
Igor Yakovlev 4a49261f8c [Wasm/WASI] Implement Wasm WASI box test for K2
Fix #KT-64449
2024-01-24 15:41:38 +00:00
Igor Yakovlev a5dd71ac93 [Wasm] Generate wat in tests if compiler key is set 2024-01-24 15:41:38 +00:00
Mikhail Glukhikh 51093a4764 K1/K2: add a group of BB test around primitives in Java
Related to KT-62554, KT-63242
2024-01-24 08:39:18 +00:00
Vladimir Sukharev 39e2187d31 [K/N][Tests] Split filecheck part from test direct.kt
^KT-61259
2024-01-19 18:31:25 +01:00
Vladimir Sukharev 1b18f4ed1e [K/N][Tests] Migrate first ObjC test with framework
^KT-61259
2024-01-19 18:22:20 +01:00
Alexander Udalov b2c30921e4 JVM: support JVM-specific primitive/wrapper type overridability check
#KT-62045 Fixed
2024-01-19 12:30:48 +00:00
Vladimir Sukharev 80cf88c9b9 [K/N][Tests] Move threadStates tests to common codegen/box folder
^KT-61259
2024-01-16 20:15:25 +00:00
Artem Kobzar a55c65e3e2 [K/Wasm] Add simple TypeScript definitions generating ^KT-65009 Fixed 2024-01-16 11:10:27 +00:00
Pavel Kunyavskiy 882dc18e0e [IrActualizer] Don't copy attributeOwnerId in actualizer
In before, actualizer was copying attributeOwnerId to new
nodes. This leads to attributeOwnerId linked to non-actualized
node. It's unclear what it leads to, so we just stop doing that.

In particular, if attributeOwnerId references another node,
this information would be lost.

^KT-64895
2024-01-15 14:10:35 +00:00
Igor Yakovlev 931cc48def [Wasm/WASI] Implementation of a callback on root exported function exit
Fixed #KT-64486
2024-01-15 11:37:37 +00:00