Commit Graph

109834 Commits

Author SHA1 Message Date
Ilya Chernikov 1989e8f094 IC tests: add infrastructure for K1/K2 lookups comparison
Adapt lookup tests to allow running K1 and K2 on the same testdata
and compare the lookups recorded.
2024-03-12 11:38:06 +00:00
Ilya Chernikov 684d0b8690 K2 IC: filter out builtins lookups
Do not record lookups to kotlin builtins, since it is considered
useless.

Related to #KT-66417
2024-03-12 11:38:06 +00:00
Ilya Chernikov 5b62558798 K2 IC: fix member lookup recording
The previous code recorded only class name, instead of fqname,
as a scope of lookup.

#KT-65943 fixed
#KTIJ-24828 fixed
related to #KT-56197
2024-03-12 11:38:06 +00:00
Kirill Rakhman f38dc3999c [FIR] Reformat SignatureEnhancement 2024-03-12 10:29:45 +00:00
Kirill Rakhman 0889770ccd [FIR] Fix scope of Java classes that inherit multiple properties with the same name
Use the receiver and context receiver types in addition to the property
name as cache keys for the synthetic property generation.
Also, fix logic that searches for accessor overrides by comparing
receiver and context receiver types.
Finally, let synthetic properties delegate their receiverParameter and
contextReceivers to their accessors.

#KT-65464 Fixed
#KT-66195
2024-03-12 10:29:45 +00:00
Kirill Rakhman 89ecb92551 [FIR] Support deferred return type computation for synthetic properties
#KT-66048 Fixed
2024-03-12 10:29:45 +00:00
Kirill Rakhman 973e337bf5 [FIR] Enhance getter overrides based on overridden properties
The following tests are failing with exceptions and will be fixed in the
following commits

j+k/testKjkPropertyAndExtensionProperty.kt
j+k/testKjkImplicitReturnType.kt

#KT-62118 Fixed
2024-03-12 10:29:45 +00:00
Kirill Rakhman 885ba11d97 [FIR] Defer computation of enhanced return type when overridden has implicit return type
#KT-66048
2024-03-12 10:29:45 +00:00
Kirill Rakhman 888cac6fc0 [Tests] Reproduce #KT-66048 2024-03-12 10:29:45 +00:00
Kirill Rakhman 29a9d3cdd9 [FIR] Fix copy paste error in receiver enhancement 2024-03-12 10:29:44 +00:00
Kirill Rakhman 8a90032e93 [FIR] Refactor deferred computation of callable copy return types
Rename some classes for clarity and move the implementations to the use
sites.
2024-03-12 10:29:43 +00:00
Vladimir Sukharev aa1cce78c3 [FIR] Incorrect warnings about inline function impact
^KT-65959 Fixed
2024-03-12 10:26:23 +00:00
Denis.Zharkov 232c3aeadc K2: Fix PCLA breaking change when using a bare type on a type variable
See the change at docs/fir/pcla.md and the kdoc
at `getAndSemiFixCurrentResultIfTypeVariable` for clarification

^KT-64840 Fixed
2024-03-12 10:22:11 +00:00
Denis.Zharkov 141be17b4b K2: Add some more tests showing the state for KT-64840
lambdaParameterForBareTypeEarlyFixationAffectsBehavior.kt
should show in the future commits how early variable fixation
necessary for bare type information might affect inference results

^KT-64840 Related
2024-03-12 10:22:11 +00:00
Anton Lakotka a56dc7d73a [Gradle] Don't resolve Apple-specific Cinterops on Linux & Windows
Resolving such dependencies was lenient, however it produced
a lot of annoying error messages in the IDE. Because "file not found".

KGP already warns user if they are declared Apple-specific targets
on non-macos machine.

^KT-66514 Verification Pending
2024-03-12 09:54:08 +00:00
Anton Lakotka e2336e1752 [Gradle] Fix friendArtifactResolver for External Targets API
It was failing with ClassCastException in an attempt of using it.

Also added a test case to cover the logic with friendArtifactResolver

^KT-66431 Verification Pending
2024-03-12 09:52:57 +00:00
Timofey Solonin 5873127342 Apply resolution strategy before applying KGP in resources tests
^KT-66133
2024-03-12 09:38:52 +00:00
Timofey Solonin 1849f17228 Make variant reselection the default resolution strategy
^KT-66133
2024-03-12 09:38:52 +00:00
Timofey Solonin c34bfcdb1d Emit a diagnostic if variant reselection is used pre Gradle 7.6
^KT-66133
2024-03-12 09:38:52 +00:00
Ivan Kylchik e1180adfbd [Native] Always cast expression to the expected type after inline
Right now, during the process of inlining, the compiler erases types.
Because of that, we can end up with some random type
(for example, `Any`) where the concrete type was
expected (for example, `Int`). Compiler must insert a cast in the
required places.

#KT-66017 Fixed
2024-03-12 08:19:50 +00:00
Dmitriy Novozhilov 555cf56d6d [FIR2IR] Don't manually create IR for IntrinsicConstEvaluation if not needed
There is no need to create IR class for `@IntrinsicConstEvaluation` manually
  if it is present in sources

^KT-65415 Fixed
2024-03-12 06:46:09 +00:00
Dmitriy Novozhilov 7a383373b0 [Test] Reproduce KT-65415 and KT-66432 2024-03-12 06:46:09 +00:00
Dmitriy Novozhilov d352cc9d96 [Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
2024-03-12 06:43:58 +00:00
Dmitriy Novozhilov a552238874 [Plugin API] Provide a way to register disposable callbacks in CompilerPluginRegistrar
^KT-59555 Fixed
2024-03-12 06:41:47 +00:00
Ilya Gorbunov 5afb2c5e4b [stdlib] Annotated new API with SinceKotlin(2.0) where required KT-64904 2024-03-12 01:36:46 +00:00
Ilmir Usmanov 1c4023fda5 FIR: Report CAPTURED_VAL_INITIALIZATION if initialization is done
outside of constructor.

In other words, when EXACTLY_ONCE lambda initializes non-static final
field of a class, the lambda has to be inlined, otherwise, backend
generated separate function of separate class for the lambda,
which lead to exception at runtime.

 #KT-64854 Fixed
 #KT-59906 Fixed
2024-03-12 00:42:07 +00:00
Marco Pennekamp 5dec87eba8 [LL] Use soft references in FileStructureCache
- We can also soft-reference the `KtFile` key. Chances are, if the
  `KtFile` can be garbage-collected, we do not need a `FileStructure`
  instance for it either.

^KT-65978 fixed
2024-03-11 23:07:04 +00:00
Dmitrii Gridin 8de680314e [SLC] reuse toLightClass for inner classes creation
This means:
* We will call `checkCanceled` under the hood.
* We will cache and reuse the result of conversion.

^KTIJ-28688
2024-03-11 21:42:39 +00:00
Dmitrii Gridin 2f2a17f570 [SLC] inject checkCanceled into declarations creation to improve responsiveness
^KTIJ-28688
2024-03-11 21:42:39 +00:00
Dmitrii Gridin 0ab105f265 [LC] KotlinAsJavaSupportBase: add checkCanceled
The jump from Kt into the Psi world is a good place to check
if we have been canceled

^KTIJ-28688
2024-03-11 21:42:39 +00:00
Vadim.Mishenev df1d44b15f KT-64051 [AA] Fix resolve of KDoc references to a typealias by full name 2024-03-11 21:38:09 +00:00
Vladimir Dolzhenko 8b7ca9527a Inject checkCanceled calls to improve responsiveness
#KTIJ-28688


Co-authored-by: Dmitrii Gridin <dmitrii.gridin@jetbrains.com>

Merge-request: KT-MR-14866
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2024-03-11 20:47:30 +00:00
Igor Yakovlev 84a5a9ff53 Revert "[Wasm] Implement IrLinkageError end enable partial linker"
This reverts commit c0f387dbd1.
2024-03-11 19:27:12 +00:00
Dmitrii Krasnov a33e56a50d [Gradle IT] Added ivy with release k/n to IT tests default repos
^KT-64903
2024-03-11 18:33:16 +00:00
Brian Norman 9a5f4522e6 [PowerAssert] Update Gradle extension to be more idiomatic
Instead of using raw List types in the Gradle extension, ListProperty
should be used instead to make it more Gradle idiomatic. Also marking
the extension and all properties as experimental to allow easier
changing in the future.

^KT-65952 Fixed
2024-03-11 18:18:49 +00:00
Ilya Gorbunov ae3e770246 Update line numbers from stdlib in inlining and stepping tests 2024-03-11 18:12:27 +00:00
Ilya Gorbunov 7175680917 [stdlib] Specify EXACTLY_ONCE contract for useLines 2024-03-11 18:12:27 +00:00
Ilya Gorbunov ed8c71442b [stdlib] Use more idiomatic index range check in getOrElse/Null 2024-03-11 18:12:27 +00:00
Ilya Gorbunov fc13ae7b4d [stdlib] Specify AT_MOST_ONCE contract for default-value-like functional parameters KT-54879 2024-03-11 18:12:27 +00:00
Ilya Gorbunov dee9fdc02d [stdlib] Regenerate sources 2024-03-11 18:12:27 +00:00
Nikita Bobko 989ec97bb0 [FIR] Make FirNotImplementedOverrideChecker to run only for non-expect classes or in metadata compilation
^KT-64187 Fixed
Review: https://jetbrains.team/p/kt/reviews/14807

I also checked that IDE sets metadataCompilation to `true` (Actually, it
looks like IDE performs analysis two times with the flag having
different values, but whatever, maybe it's even better this way)
2024-03-11 18:07:52 +00:00
Nikita Bobko 9d566465e6 [test] Run checkers in metadata-like style to see what diagnostics metadata compilation omits
Review: https://jetbrains.team/p/kt/reviews/14807

Technically, *.ll.kt should have been covering that. But I see that
there slight differences
2024-03-11 18:07:52 +00:00
Nikita Bobko ab069cb7f4 [test] Use correct FirOutputPartForDependsOnModule for running checkers that run in common session
Review: https://jetbrains.team/p/kt/reviews/14807

Motivation: no motivation, I was just passing by and noticed this bug.

It looks like this commit doesn't affect any tests
2024-03-11 18:07:51 +00:00
Mikhail Glukhikh c4bcdc42c1 K2: don't count use-sites of Java type parameter with nullable bounds as not null 2024-03-11 18:05:04 +00:00
Mikhail Glukhikh d353fd400d K1/K2: add a test for KT-50008 2024-03-11 18:05:04 +00:00
Alexander Udalov 2f056fe155 JVM: remove StubClassBuilder and its usage
After legacy light classes were removed, the only remaining usage was in
KotlinLightClassBuilderFactory where we ran JVM backend in the
LIGHT_CLASSES mode, and that was only used from diagnostic tests to
report JVM backend diagnostics.

We don't actually need to build stubs here, so we can just use ASM's
class writer, which means that StubClassBuilder and all its dependencies
can be removed.
2024-03-11 18:03:49 +00:00
Sonya Valchuk e5ad035039 JVM: do not write trivial SMAPs to any classes
Even ones inside inline functions. This was a backwards compatibility
hack for Kotlin 1.4, where the inliner would crash if it attempted to
regenerate an anonymous object with no SMAP; that has been fixed in 1.5,
and ever since then trivial SMAPs could be inferred from line number
markers in methods.

There are three kinds of changes to tests in this commit:

  * Some SMAPs are gone entirely - self-explanatory.

  * Some SMAPs have narrower line ranges - that's because the old SMAP
    had the range for the entire file, while the new one only maps up to
    the last line number used in the class. There should be no
    difference in behavior.

  * Some "source file name" markers are removed in continuation objects
    - continuations don't have any line numbers, so there's no debugging
    information anyway. The actual source information is in the
    containing class.
2024-03-11 17:25:50 +00:00
Sonya Valchuk fc992274bb JVM: make SMAP utilities a little prettier 2024-03-11 17:25:50 +00:00
Vladimir Sukharev 64d4b61628 [Tests] Drop obsolete KotlinJavascriptSerializerTest.kt 2024-03-11 15:12:44 +00:00
Vladimir Sukharev 9b4f503fbe [Tests] Port KotlinKlibSerializerTest to K2
^KT-64440 Fixed
2024-03-11 15:12:44 +00:00