Commit Graph

99695 Commits

Author SHA1 Message Date
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
Sergej Jaskiewicz 1bfedb6426 [test] Move JVM-specific irText test classes to separate files 2023-03-22 15:18:18 +00:00
Sergej Jaskiewicz 88b7f30867 [test] Use custom ignore directive for AbstractKlibJsTextTestCase tests
We've muted some irText tests on JS in the previous commits because
test expectations in some tests are different when targeting JS.

AbstractKlibJsTextTestCase tests use a different logic:
they compare the dump of the deserialized IR with the frontend-generated
IR, not with the expectations in text files, thus muted tests weren't
actually failing.

Here we introduce a temporary fix, namely
a separate // IGNORE directive for klib tests.

When klib tests are moved to the new test infrastructure, there will be
no need to do this.
2023-03-22 15:18:17 +00:00
Sergej Jaskiewicz 27ccef868a [test] Run irText tests against K1 frontend for JS 2023-03-22 15:18:17 +00:00
Sergej Jaskiewicz 502a0b7e10 [test] Move JS-targeting irText test runners to js-specific directory 2023-03-22 15:18:17 +00:00
Sergej Jaskiewicz b57f436a44 [test] Mute failing irText tests 2023-03-22 15:18:16 +00:00
Sergej Jaskiewicz 7dba138da6 [test] Don't run K2-specific irText tests against K1 2023-03-22 15:18:16 +00:00
Sergej Jaskiewicz 98e497509a [test] Don't run JS-specific irText tests against other backends 2023-03-22 15:18:16 +00:00
Sergej Jaskiewicz 17a8fd2c0b [test] Move irJsText tests to irText directory
So that all irText tests could be found in one place
2023-03-22 15:18:15 +00:00
Sergej Jaskiewicz ebafdd3af0 [test] Move irText tests from fir2ir/testData to compiler/testData
Let's store them conveniently in one place!
2023-03-22 15:18:15 +00:00
Sergej Jaskiewicz c1ea3e7b53 [test] Give IrText test classes more descriptive names
The names now reflect the frontend and the backend used to run the tests
2023-03-22 15:18:15 +00:00
Pavel Kunyavskiy b01cc1f88c [K2/N] Fix property accessors modality in K2 metadata
^KT-56603
2023-03-22 13:47:01 +00:00
Ilya Chernikov aa3c189d83 FIR: fix return statement generation for Unit-returning lambdas...
for case then the expected return type is not Unit.
#KT-56747 fixed
2023-03-22 13:23:24 +00:00
Nikolay Lunyak 505edb9746 [FIR2IR] KT-57211: Support unsigned arrayOf-s in fir2ir
^KT-57211 Fixed

Merge-request: KT-MR-9294
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-03-22 13:10:17 +00:00
Dmitrii Gridin a5e5e093c3 [LL FIR] pass correct phase to AbstractLazyBodyIsNotTouchedTest test
We have lazy expressions on ARGUMENTS_OF_ANNOTATIONS,
so we should decrease the phase to it

^KT-56543
2023-03-22 14:08:39 +01:00
Ilya Goncharov 956682d1ca [Gradle, JS] No specific handling of composite dependencies
^KT-47351 fixed
2023-03-22 13:05:34 +00:00
Alexander Udalov 1bc299508a Fir2Ir: do not skip building static fake overrides for enums
Fake overrides are needed at least for static fields inherited from Java
interfaces. Not static methods though, because they are not inherited.

 #KT-57302 Fixed
2023-03-22 12:34:05 +00:00
Dmitrii Gridin c046bedfc2 [AA FIR] FirLazyAnnotationTransformer: fix resolve contract violation
We can't reduce resolve to COMPILER_REQUIRED_ANNOTATIONS phase for
annotations with arguments, because currently they don't have
argument mapping

```stracktrace
org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: By now the annotations argument mapping should have been resolved
	at org.jetbrains.kotlin.analysis.api.fir.annotations.FirAnnotationUtilsKt.mapAnnotationParameters(firAnnotationUtils.kt:137)
	at org.jetbrains.kotlin.analysis.api.fir.FirUtilsKt.toKtAnnotationApplication(FirUtils.kt:79)
	at org.jetbrains.kotlin.analysis.api.fir.annotations.FirAnnotationUtilsKt.annotationsByClassId(firAnnotationUtils.kt:60)
	at org.jetbrains.kotlin.analysis.api.fir.annotations.FirAnnotationUtilsKt.annotationsByClassId$default(firAnnotationUtils.kt:46)
```

^KT-57424 Fixed
2023-03-22 10:33:27 +01:00
Ilya Gorbunov 9892a49c4b KT-54452 Use js-ir sources for building stdlib-js sources.jar and API docs 2023-03-22 05:57:14 +00:00
Ivan Kochurkin cd07eba25c [K2, MPP] Fix reporting of MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED 2023-03-22 01:28:19 +00:00
Ivan Kochurkin 60edf1def3 [K2, MPP] Support actualization of enums and annotations that have primary constructor with arguments
^KT-57241 Fixed
2023-03-22 01:28:18 +00:00
Ivan Kochurkin 44807b7bd4 [K2, MPP] Support actualization of actual function with dynamic arguments
^KT-57210 Fixed
2023-03-22 01:28:18 +00:00
Ivan Kochurkin ce7af9ff2b [K2, MPP] Support arguments with expect types in actual functions 2023-03-22 01:28:18 +00:00
Ivan Kochurkin ec34b9fa7b [K2, MPP] Restore ir functions actualization by argument types instead of full signatures
Refactor IrActualizer
2023-03-22 01:28:17 +00:00
Ivan Kochurkin d99b4c78d2 [K2, MPP] Correct actualization of nested objects
^KT-57182 Fixed
2023-03-22 01:28:17 +00:00
Ivan Kochurkin 8a3e2543f7 [K2, MPP] Ignore MPP tests in DiagnosisCompilerTestFE10TestdataTestGenerated 2023-03-22 01:28:17 +00:00
Ivan Kochurkin ceb34e5a8a [K2, MPP] Introduce IGNORE_FIR2IR_EXCEPTIONS_IF_FIR_CONTAINS_ERRORS
Use it for K2 MPP tests
2023-03-22 01:28:16 +00:00