Commit Graph

99721 Commits

Author SHA1 Message Date
Ivan Kochurkin ee73e4774b [K2, MPP] Remove redundant expect declarations from klib metadata
^KT-57250 Fixed

Introduce flat Fir2IrActualizedResult

It contains output from Fir2Ir and IrActualizer
2023-03-24 14:48:26 +00:00
Ivan Kochurkin d91efb212d [K2, MPP] Rename jvm.kt to platform.kt in JS tests 2023-03-24 14:48:24 +00:00
Ivan Kochurkin 227018624e [K2, MPP] Add common constructorCache to Fir2IrCommonMemberStorage
Use it in Fir2IrDeclarationStorage

^KT-56660 Fixed
2023-03-24 14:48:24 +00:00
Mikhail Glukhikh 930237b60e K1: report swallowed diagnostic about upper bound violation
#KT-55055 Fixed
2023-03-24 14:27:03 +00:00
Denis.Zharkov b148df15a9 Fix project compilation
Compilation was broken becaise of the combination of
706ff6b61f and
9c2c11f7e9
2023-03-24 14:53:14 +01:00
Alexander Udalov 562b27db4e JVM IR: initialize enum entries without invokedynamic
#KT-57316 Fixed
2023-03-24 13:38:32 +00:00
Denis.Zharkov 9c2c11f7e9 FIR2IR: Fix "expected FirResolvedTypeRef but was FirJavaTypeRef" crash
The problem was that we were using unenhanced constructors that still
might contain java type refs.
Basically, most of the `firClass.declarations` usages are unsafe in that
meaning.

The test is very complicated because to reproduce the exception there
should be some conditions met:
- MyClass should be compiled with K1, so it has `@EnhancedNullability`
annotation serialized (that is unnecessary, but don't do any harm)
- `@Nls` scope should be properly resolved, so enum entries are converted
to resolved type refs
- That leads to attempt to check if null-check might be needed to be
inserted and to failure at FirTypeUtilsKt.getCanBeNull

While this quite controversial to have this check being performed for
freshly created annotations calls, the problem with improper constructor
lookup anyway existed and fixed correctly.

^KT-57213 Fixed
2023-03-24 13:07:42 +00:00
Dmitrii Gridin a643dfbe83 [FIR][tree] introduce lazy expression to simplify code
^KT-56543
2023-03-24 09:58:38 +00:00
Dmitrii Gridin bc5c1b2a6c [LL FIR] add test on lazy resolve annotation with type argument
^KT-56543
2023-03-24 09:58:11 +00:00
Dmitrii Gridin 8c599a84af [FIR][renderer] add phase renderer for file and file annotations container
^KT-56543
2023-03-24 09:58:11 +00:00
Dmitrii Gridin 706ff6b61f [FIR] pre-resolve some scope callables before creating a scope
In a lot of cases, when we want to process the
declaration in scope, it should be resolved to at least TYPES phase.

To avoid doing it manually in all our variety of scopes, we do it when the scope it created.
It was implicitly working manually before as lazy resolve did a lot of extra work
on resolving a declaration it was not supposed to resolve.
Now it's not the case, and we have to explicitly resolve all the declarations we need.

^KT-56543

Co-authored-by: Ilya Kirillov <ilya.kirillov@jetbrains.com>
2023-03-24 09:57:46 +00:00
Ilya Kirillov 23e40693a3 [LL FIR] add api to FirLazyDeclarationResolver to resolve class with callable members
^KT-56543
2023-03-24 09:57:45 +00:00
Mikhail Glukhikh 25cb03b707 Add test ensuring the case of KT-57022 is fixed 2023-03-24 09:12:16 +00:00
aleksandrina-streltsova b23dbd359f [AA] Flatten composite scopes when building scope context for position
^KTIJ-25048 Fixed
2023-03-24 07:42:58 +00:00
Artem Daugel-Dauge 1c72ce173f [Gradle] Remove workarounds for KT-55751 in cocoapods tests 2023-03-23 21:02:20 +00:00
Sebastian Sellmair c45a9d6510 [Gradle] KotlinNativeTasks: buildDependencies: Add naive dependency loop protection
^KT-57531 Verification Pending
2023-03-23 20:56:41 +00:00
Sebastian Sellmair 89df0ed213 [Gradle] KotlinNativeTasks: buildDependencies: Filter constraint dependencies
^KT-57531 Verification Pending
2023-03-23 20:56:41 +00:00
Sebastian Sellmair 3f4b37693f [Gradle] Implement test Kotlin Native Link with cycle in dependency constraints
... to cover KT-57531
2023-03-23 20:56:41 +00:00
Pavel Mikhailovskii 0e6da53af8 KT-57491 Prefix context receivers with $context_receiver_ 2023-03-23 16:23:09 +00:00
nataliya.valtman f3592088fe Temporary Ignore flaky test 2023-03-23 16:05:01 +00:00
Sergej Jaskiewicz 691d9abde6 [test] Unmute irText tests that don't fail on K2 anymore 2023-03-23 15:24:32 +00:00
Abduqodiri Qurbonzoda 9076e5b112 [K/N] Mark BitSet usages in stdlib with @ObsoleteNativeApi 2023-03-23 14:48:23 +00:00
Abduqodiri Qurbonzoda 9ff863ced7 [K/N] Mark BitSet with @ObsoleteNativeApi #KT-57088 2023-03-23 14:48:23 +00:00
Abduqodiri Qurbonzoda 3ffbfba1d6 [K/N] Introduce ObsoleteNativeApi annotation
An opt-in annotation to mark the Kotlin/Native standard library API
that is considered obsolete and is being phased out.
2023-03-23 14:48:22 +00:00
Mikhail Glukhikh 9af944669a FIR2IR: bind fake overrides for classes on the fly right after member processing
#KT-57441 Fixed
2023-03-23 13:12:18 +00:00
Mikhail Glukhikh d3f1571d35 FIR2IR: add repro for KT-57441 2023-03-23 13:12:17 +00:00
nataliya.valtman d6a9bca5ec Create plugin for test to set language and api kotlin versions 2023-03-23 12:34:01 +00:00
Pavel Kunyavskiy 1c2f34ab4e [K/N] Add test for Annotations on type parameters and update doc
^KT-57404
2023-03-23 10:27:23 +00:00
Dmitriy Dolovov 66c278ff8d [JS][IC][test] Remove testBreakKlibBinaryCompatibilityWithVariance test
#KT-57078 Fixed
2023-03-23 10:24:28 +00:00
Dmitriy Dolovov 153aed29ba [JS][IC][test] Fix step numbers in tests 2023-03-23 10:24:28 +00:00
Dmitriy Dolovov 3e7043e1f5 [PL] Remove filters for PL warnings in NativeTestGroupingMessageCollector
Normally, all PL warning messages should have non-null location. Thus, no need to have a specific filter for them.
2023-03-23 10:24:28 +00:00
Dmitriy Dolovov 295c578f44 [PL] Rename IDEA run configurations for ABI compatibility tests
Also: Run Native ABI tests with '--stacktrace' option turned on.
2023-03-23 10:24:27 +00:00
Dmitriy Dolovov 4f1155b06f [PL] ABI compatibility tests for reworked partial linkage 2023-03-23 10:24:27 +00:00
Dmitriy Dolovov 2a4d880037 [PL] Deep rework of the partial linkage
1. Leaving no unbound symbols in the IR tree, KT-54491:
   - All unbound symbols are bound to synthetic stub declarations
   - Improved detection of the root cause for every partially linked classifier
   - Improved error messages

2. Visibility valiation, KT-54469

3. Always check deserialized symbols:
   If the deserialized symbol mismatches the symbol kind at the call site in the deserializer then generate and reference another symbol with the same signature. In case PL is off, just throw IrSymbolTypeMismatchException.

4. Handle class inheritance violation:
   - Detect illegal inheritance (ex: inheriting from a final class)
   - Detect invalid constructor delegation (ex: delegating to another class than the direct superclass)
   - Simplification: Reduce the number of PartialLinkageCase subclasses
   - Reworked error message generation to have shorter and clearer messages

5. Handle class transformations and all known side-effects, examples:
   - nested <-> inner
   - class <-> enum/object
   - adding/removing subclasses of sealed class
   - adding/removing enum entries

6. Check direct instantiation of abstract class.
   Such instantiation could be possible if a class was non-abstract in the previous version of a library.

7. Handle unlinked annotations on declarations.
   Such annotations are removed from the IR. The appropriate compiler error message is produced for every individual case.

8. Handle value argument count mismatch at call sites

9. Handle calling suspend function from non-suspend context.
   This could happen if a suspen function was non-suspend in the previous version of a library.

10. Handle overriding inline callables.
    Only the leaf final callable can be marked with `inline`.

11. Detect illegal non-local returns from noinline/crossinline lambdas.
2023-03-23 10:24:27 +00:00
Dmitriy Dolovov 974ee3139c [PL] Track all unbound symbols produced by the partial linkage.
With the partial linkage turned on it's hard to predict whether a newly created IrSymbol that is added to the SymbolTable via one of referenceXXX() calls will or won't be bound to some declaration. The latter may happen in certain cases, for example when the symbol refers from an IR expression to a non-top level declaration that was removed in newer version of Kotlin library (KLIB). Unless such symbol is registered as "probably unbound" it remains invisible for the linkage process.

The optimization that allows to reference symbols without registering them as "probably unbound" is fragile. It's better to avoid calling any referenceXXX(reg = false) functions. Instead, wherever it is s suitable it is recommended to use one of the appropriate declareXXX() calls.

For the future: Consider implementing the optimization once again for the new "flat" ID signatures.

Also: Temporarily mute assertion that checks symbols overwrites in SymbolTable ^KT-57049
2023-03-23 10:24:26 +00:00
Dmitriy Dolovov f99ad3be3b [PL][Native] Fix: Preserve origin while applying ThrowIrLinkageError intrinsic 2023-03-23 10:24:26 +00:00
Dmitriy Dolovov dc05683f59 [PL][tests] Fix: Properly count test steps in KLIB ABI compatibility tests 2023-03-23 10:24:26 +00:00
Dmitriy Dolovov c38d0d7359 [IR] Refactoring: Clean-up in ExternalDependenciesGenerator
Note: There is no need to catch KotlinIrLinkerInternalException and
re-throw it as CompilationErrorException since the fix of KT-53649.
2023-03-23 10:24:25 +00:00
Dmitriy Dolovov eec511a767 [PL] Fix line/column numbers in error messages 2023-03-23 10:24:25 +00:00
Marco Pennekamp 9a3eece944 [LL FIR] KTIJ-24895 Record compound assignments with error names
- If the callee reference in a desugared compound assignment was an
  error reference, the compound assignment wasn't cached by
  `FirElementsRecorder`. This led to KTIJ-24895 (see the issue for more
  details).
- The solution falls back on the compound assignment's source to decide
  `isSourceForCompoundAccess`, as an operation name can be reconstructed
  from the PSI.

^KTIJ-24895 fixed
2023-03-23 10:14:57 +00:00
Ilya Goncharov d14a55d775 [Gradle, JS] Remove redundant composites in K/JS Gradle Plugin
KT-47351
2023-03-23 10:13:00 +00:00
Vladimir Sukharev 9407ec35e3 KT-57487: Add codegen test
Merge-request: KT-MR-9300
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-03-23 10:03:00 +00:00
Nikolay Lunyak a2e2a96fd3 [FIR] KT-56846: Unwrap SourceCodeAnalysisException on transformFile
^KT-56846 Fixed

Merge-request: KT-MR-9065
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-03-23 09:54:43 +00:00
Nikolay Lunyak 7b04201e77 [FIR] KT-57104: Preserve @JvmName on fake-override accessors
Otherwise, when we come to `ClassCodegen.kt:173
for `GradleActionTest` and check
`FUN FAKE_OVERRIDE name:<get-project>`,
we then go to `JvmSignatureClashDetector.kt:37`,
and call `mapRawSignature(overriddenFunction)`
which ignores the original `@JvmName`.
It does so because it relies on the property copy
which forgets to copy the getter, but
`@get:JvmName` is stored in it.

Extra when-branches for `FAKE_OVERRIDE` are needed,
because otherwise the annotations would not
be copied in `Fir2IrDeclarationStorage.kt:723`.

Extra when-branches for `DELEGATED_MEMBER` are
needed, because otherwise the generated IR changes
in some tests. For example, see:
`FirLightTreeIrTextTestGenerated.Declarations.testKt35550`.

The `assumesBackingField`-related change is backed by
the `FirLightTreeIrTextTestGenerated.Stubs.testJavaEnum` test.

`this.body = null` ensures the resulting IR
matches K1.

The change in `FirImplicitBodyResolve.kt` is needed,
because otherwise the bootstrap compiler fails at
`:compiler:frontend:compileKotlin`,
but I didn't come up with a smaller test for it.

If we don't make an explicit accessor copy,
then when we later create a `Fir2IrLazyPropertyAccessor`
for the fake override getter, it's `fir` will
be a reference to the `FirProperty`, not `FirPropertyAccessor`.
That's why `DumpIrTreeVisitor` will render `IntrinsicConstEvaluation` as
a getter annotation as well.

`FirPsiIrTextTestGenerated.testDelegatedGenericImplementation`
renders type parameters from `<get-x>`,
because when assigning `extensionReceiverParameter`
of the setter `<set-x>` we come to
`Fir2IrClassifierStorage.kt:638`,
and in this cache there's the parameter with
the `<get-x>` parent.
Note that `typeContext.origin == DEFAULT` in
`getCachedIrTypeParameter`.
It's `DEFAULT` because at the line `Fir2IrDeclarationStorage.kt:335`
the `function` variable is `null` (because there's no setter).

The change in `declarationAttributes.kt` is backed
by the `FirPsiIrTextTestGenerated.testKt45853` test.

^KT-57104 Fixed
^KT-57432 Fixed

Merge-request: KT-MR-9210
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-03-22 18:16:31 +00:00
Dmitrii Gridin 9a4a3d1f49 [LL FIR] introduce test with reversed resolve order
^KT-56543

Merge-request: KT-MR-9299
Merged-by: Dmitrii Gridin <dmitry.gridin@jetbrains.com>
2023-03-22 17:34:07 +00:00
Vladimir Dolzhenko 8528519d96 Improve container error reporting with containerId
Merge-request: KT-MR-8965
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-03-22 16:34:22 +00:00
Mikhail Glukhikh eb80ba9cf7 DiagnosticReporterByTrackingStrategy: extract reportArgumentConstraintErrorByPosition 2023-03-22 15:42:26 +00:00
Mikhail Glukhikh 7a58c2e99f DiagnosticReporterByTrackingStrategy: refactor positioning 2023-03-22 15:42:26 +00:00
Mikhail Glukhikh 739e7d3a7a DiagnosticReporterByTrackingStrategy: refactor all whens by type 2023-03-22 15:42:25 +00:00
Sergej Jaskiewicz 70bcb1fdea [native] Support Native tests in Test Data Helper Plugin 2023-03-22 15:18:41 +00:00