Commit Graph

47897 Commits

Author SHA1 Message Date
Alexander Udalov 47a4ee7fdf IR, JS: remove duplicate FQ name check from hasEqualFqName
`hasEqualFqName` is called from `hasAnnotation`, which takes more than
1% of total backend time, so it's important to avoid doing extra work
here.

It seems to be a quirk of the JS IR backend specifically that
`JsExport.Ignore` has incorrect IR parent structure here; for all other
backends, checking FQ name by traversing IR parents should work fine.

 #KT-66281
2024-03-06 22:03:10 +00:00
Alexander Udalov d430673320 JVM IR: optimize type equality check on IR types
`AbstractTypeChecker.isCommonDenotableType` calls a few functions which
check if the type is flexible, which is not cheap in case of JVM IR, see
`asFlexibleType`.

 #KT-66281
2024-03-06 22:03:10 +00:00
Alexander Udalov 45b74d0313 IR: simplify IrOverrideChecker.isOverridableByWithoutExternalConditions
Inline property-related utilities to the only call site, rearrange the
code to make declarations closer to their usages, etc.
2024-03-06 22:03:10 +00:00
Wojciech Litewka cbabfc0fe2 [IR] Drop ir.ir2cfg module
#KTI-952 Fixed
#KT-65773 Related
2024-03-06 18:30:22 +00:00
Ilmir Usmanov 0bb6359ac5 Minor. Add regression tests
#KT-64725 Fixed
 #KT-64726 Fixed
 #KT-64727 Fixed
2024-03-06 18:16:59 +00:00
Denis.Zharkov b7129f78a3 K2: Fix IAE at Candidate.updateSourcesOfReceivers inside PCLA lambda
Previously, it was failing at line
(resolvedReceiver?.toReference(session) as? FirNamedReferenceWithCandidate)?.candidate?.updateSourcesOfReceivers()

But this line was mostly incorrect because in case of `a.b()` call,
which is resolved to `a.b.invoke()`, `resolvedReceiver` is pointing to
`a` instead of obviously expected `a.b`.

The fix with using `candidate.callInfo.explicitReceiver` doesn't help
either because the candidate of that receiver is always completed at
that stage (so no Candidate there).

The only case when the candidate was still there is PCLA because
 in that case we explicitly don't fully complete even receiver
expressions.
(see docs/fir/pcla.md)

The idea of the fix is moving the call of `updateSourcesOfReceivers`
for invoke property receiver to the place just before the candidate
is being converted to the resolved reference
(i.e., the candidate is being lost)

^KT-66148 Fixed
2024-03-06 17:01:57 +00:00
Dmitrii Gridin ae9c9b051f [FIR] do not use MUTE_LL_FIR for multiplatform tests 2024-03-06 16:13:09 +00:00
Dmitrii Gridin c090ae96ab [LL FIR] update attached issue
^KT-66352
2024-03-06 16:13:09 +00:00
Dmitrii Gridin 124453016d [LL FIR] Replace IGNORE_REVERSED_RESOLVE + IGNORE_NON_REVERSED_RESOLVE with MUTE_LL_FIR 2024-03-06 16:13:09 +00:00
Dmitrii Gridin 9ea9950d28 [LL FIR] Replace IGNORE_DIAGNOSTIC_API with IGNORE_NON_REVERSED_RESOLVE 2024-03-06 16:13:09 +00:00
Dmitrii Gridin 28c80a1581 [LL FIR] StubBasedFirMemberDeserializer: add missed deprecation provider
^KT-60996 Fixed
2024-03-06 16:13:09 +00:00
Artem Kobzar 77f0cba23f [K/JS] Introduce v2015 target 2024-03-06 12:21:38 +00:00
Dmitriy Novozhilov e989e6d397 [FIR] Don't compute getter return type if synthetic property is inapplicable
Return type computation of getter for synthetic property, which is
  incompatible anyway (e.g. because there is no java in the hierarchy)
  may cause excess dependency between return types of declarations, which
  may lead to recursive problems in resolution

^KT-66313 Fixed
2024-03-06 11:56:01 +00:00
Dmitriy Novozhilov fece081265 [Test] Reproduce KT-66313 2024-03-06 11:56:01 +00:00
Ivan Kylchik ada47eb110 [K2] Add new resolve phase CONSTANT_EVALUATION
During this phase, the compiler will evaluate initializers of
const properties and defaults of annotation's constructor.
Evaluation results will be stored in corresponding attributes.

#KT-64151
2024-03-06 11:35:41 +00:00
Ilya Goncharov b157a8eae5 [Wasm] Add wasm target to Klib manifest
^KT-66327 fixed
2024-03-06 10:57:50 +00:00
Mikhail Glukhikh 5ea6f20192 K1/K2: add reproducers for KT-66229, KT-66243 and KT-66272
As all these issues aren't reproducible in K2, we may count them as fixed.
Related to KT-53478
#KT-66229 Fixed
#KT-66243 Fixed
#KT-66272 Fixed
2024-03-06 09:01:38 +00:00
Dmitriy Novozhilov b43f69364b [IR] Forcefully collect mapping of f/o for all source classes
```kotlin
// FILE: AB.kt
interface A {
    val x: Int = 1
}

interface B : A {
    // f/o val x: Int
    //    overrides: A.x
}

// FILE: C.java
public interface C extends B {
    // f/o val x: Int
    //    overrides: (B, A.x)
}

// FILE: D.java
public interface D extends C {
    // f/o val x: Int
    //    overrides: (C, A.x)
}

// FILE: usage.kt
fun test(d: D) {
    d.x
}
```

In such test backend will ask for overriddens of lazy property C.x only
  after property lowering, which removes property `B.x` and replaces it
  with getter `B.<get-x>`. That fact that there is no property anymore
  really confuses `SpecialFakeOverrideSymbolsResolver` during computation
  of overriddens of `C.x`.
So, to prevent this situation, we can process all source kotlin classes
  beforehand, so when any lazy function/property will start computation
  of its overriddens, there won't be the need to calculate mapping of
  f/o for classes

This problem was found during work on KT-66341, after total signature
  computation removal from fir2ir. Previously those fake-overrides just
  matched by signature in symbol table
2024-03-06 08:28:24 +00:00
Dmitriy Novozhilov e8f8399af4 [FIR2IR] Properly cache generated data/value class members
FIR instances of generated toString/hashCode/equals are session dependant,
  so we need some cache, which operates only session-independent stuff.
  Pair of `FirClass` and `Name` was chosen here

Previously SymbolTable played the role of this cache (with signatures as
  keys). But it should be replaced in scope of KT-66341 and KT-64990
2024-03-06 08:28:24 +00:00
Dmitriy Novozhilov 52f6868b74 [FIR2IR] Don't compose signatures if f/o building with FIR is disabled
^KT-66341 Fixed
2024-03-06 08:28:24 +00:00
Dmitriy Novozhilov 3166a61b15 [FIR2IR] Remove unused methods from FirBasedSignatureComposer
^KT-66341
2024-03-06 08:28:24 +00:00
Kirill Rakhman 4c93e9cff6 [FIR] Fix captured type arguments of local class as callable reference LHS
#KT-66267
2024-03-06 08:22:42 +00:00
Kirill Rakhman 66212c0ec6 [FIR] Add todo about isValidTypeParameterFromOuterDeclaration
#KT-66349
2024-03-06 08:22:41 +00:00
Dmitriy Novozhilov 624bea3ecf [FIR] Never create ConeSubstitutorByMap with empty substitution
Relates to KT-66323
2024-03-06 06:40:28 +00:00
Mikhail Glukhikh e8ba534904 K1/K2: add tests confirming behavior of remaining KT-63242 cases 2024-03-05 20:19:02 +00:00
Kirill Rakhman b4413776ab [Raw FIR] Build if - else if - else as two nested whens
This is necessary for inference to work like in K1 because we only
add equality constraints from expected types on top-level `when`, not
on nested ones.

#KT-65882
2024-03-05 17:38:59 +00:00
Kirill Rakhman 888c1defa0 [FIR] Improve source selection for NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER 2024-03-05 17:38:59 +00:00
Kirill Rakhman c9d23f795a [FIR] Use named arguments in ConeBuiltinTypeUtils 2024-03-05 17:38:59 +00:00
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
Kirill Rakhman eaef7122f6 [FIR] Update WithExpectedType.toString 2024-03-05 17:38:58 +00:00
Kirill Rakhman 0e7fc3bafe [FIR] Use correct origin for value and type parameters of synthetic functions 2024-03-05 17:38:57 +00:00
Igor Yakovlev c0f387dbd1 [Wasm] Implement IrLinkageError end enable partial linker
KT-58088
2024-03-05 17:17:32 +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
Mikhail Glukhikh a77a1cf3db K1/K2: add test confirming correct work of KT-63487 case 2024-03-05 14:51:15 +00:00
Alexander Udalov 9a7d7483a3 IR: simplify IrFakeOverrideBuilder.isMoreSpecific
Using the logic from `OverridingUtil.isMoreSpecific` as a reference.
2024-03-05 14:48:23 +00:00
Vladimir Sukharev 848cca03c0 [Tests] Add tests for KT-40180
^KT-40180 Fixed
2024-03-05 13:37:26 +00:00
Wojciech Litewka eec14f0054 [tree generator] Remove Suppress("unused") from implementation classes
Those only implement base classes, their members are not supposed
to be referenced directly (those sometimes they are).
So unused code in there can be suspicious.

On the other hand, some generated builders are truly unused, so leave
the suppression for them.
2024-03-05 13:06:03 +00:00
Mikhail Glukhikh 584d98cd72 K2: add a BB test confirming work of KT-63588 2024-03-05 11:09:51 +00:00
Alexander Udalov 77b3f415a5 IR: fix "most specific" check in IrFakeOverrideBuilder
There were several problems with it:

1) `isMoreSpecific` should return true if a == b. Otherwise
   `isMoreSpecificThenAllOf` would never return true because it's always
   invoked with a collection that contains the candidate. K1 behaves
   similarly, `OverridingUtil.isMoreSpecific` returns true if a == b.
   So in fact, "more" should be understood as "not less" here.
2) `transitivelyMostSpecificMember` in `selectMostSpecificMember` was
   always equal to the first element, so `isMoreSpecific` was invoked
   with incorrect arguments.
3) At the end of `selectMostSpecificMember`, we selected the first
   candidate with the non-flexible return type, however only dynamic
   type was considered. We need to check `isFlexible` via type system
   instead.

 #KT-66120 Fixed
2024-03-05 09:19:38 +00:00
Dmitriy Novozhilov a08df1821f [FIR] Provide suppression from primary value parameter to property
`@Suppress` annotation has `VALUE_PARAMETER` target, so when a property
  in the primary constructor is annotated with `@Suppress` it sticks
  to the parameter. But the suppression should work for all diagnostics
  reported on the parameter **and** the property

^KT-66258 Fixed
2024-03-05 07:59:26 +00:00
Dmitriy Novozhilov 5e742884de [Test] Reproduce KT-66258 2024-03-05 07:59:26 +00:00
Kirill Rakhman 172df04c9b [FIR] Fix raw type nullability computation
Consider the nullability of the type arguments, not of the type.
This fixes a false positive ARGUMENT_TYPE_MISMATCH.

#KT-66294 Fixed
2024-03-05 07:45:01 +00:00
Dmitriy Novozhilov df878918ee [FIR] Optimize memory consumption of KtPsiSourceElement
There were two lazy properties in `KtPsiSourceElement`, which were
  rarely computed, which led to the fact that source element retained
  a lot of memory for those lazy delegates

^KT-66172 Fixed
2024-03-05 07:03:35 +00:00
Alexander Udalov 19cc7981dc Update test data for IR text tests 2024-03-05 06:59:11 +00:00
Alexander Udalov 3bb2ea10b6 K2: add inline JVM target version checker
#KT-60777 Fixed
2024-03-04 22:25:36 +00:00
Alexander Udalov d475371394 FIR: remove default parameter values from FirJvmSessionFactory
Most of them are passed at all call sites anyway. Having default values
makes it easy to forget to pass some meaningful argument (especially
`LanguageVersionSettingsImpl.DEFAULT` seems scary), and complicates
refactoring.
2024-03-04 22:25:36 +00:00
Alexander Udalov bacb2f0d15 K1 JVM: simplify InlinePlatformCompatibilityChecker 2024-03-04 22:25:36 +00:00
Vyacheslav Gerasimov 596aab1673 Build: Increase max metaspace size for Codegen Tests
#KTI-1610
2024-03-04 22:12:24 +00:00
anzhela.sukhanova 82255d5ee8 [Test] KT-61360: add tests for the IrFakeOverrideBuilder
Add tests for fake overrides with focus on java interoperability

Co-authored-by: Aleksandra Arsenteva <aleksandra.arsenteva@jetbrains.com>
2024-03-04 16:21:02 +00:00
Artem Kobzar 30aae741a6 [K/Wasm] Fix DROP location 2024-03-04 15:05:23 +00:00