Commit Graph

45262 Commits

Author SHA1 Message Date
Denis.Zharkov 033ff38fef K2: Adjust diagnostic test data after delegate inference is rewritten
In all tests, some red-code diagnostics have changed insignificantly
to some other combination or red-code diagnostics

^KT-61060 Related
2023-09-08 07:11:48 +00:00
Denis.Zharkov a02cb16fb2 K2: Rewrite delegate inference
The main idea is getting rid of stub types and using just type variables
See more detailed description at docs/fir/delegated_property_inference.md

The problem with stub types is that they need really special treatment
in many places, and on the other hand, there are no clear contracts on
how they should work (that regularly leads to bugs like KT-59529)

^KT-61060 Fixed
^KT-61075 Fixed
^KT-61077 Fixed
^KT-59529 Fixed
^KT-61633 Related
^KT-61618 Related
^KT-61740 Related
^KT-59107 Related
^KT-61747 Related
^KT-61077 Related
^KT-61781 Related
2023-09-08 07:11:48 +00:00
Denis.Zharkov cd5105c133 K2: Reformat FirCallCompletionResultsWriterTransformer.kt 2023-09-08 07:11:48 +00:00
Denis.Zharkov 06b0fc7e4c K2: Minor. Add comment for Candidate::substitutor 2023-09-08 07:11:48 +00:00
Denis.Zharkov f4004fb06a Add kdoc for ConstraintSystemCompletionMode.PARTIAL 2023-09-08 07:11:48 +00:00
Ivan Kylchik 6048d52a97 [K2] Avoid field inlining during FIR2IR phase
Before const inlining for fields, we actually want to remember a given
field in `InlineConstTracker`. We are doing it already in const
evaluation. So we just need to ignore const inlining in
`CallAndReferenceGenerator` and delegate it to const evaluation.

#KT-60737
2023-09-07 19:12:18 +00:00
Nikolay Lunyak f434228244 [FIR] Fix false positive POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION
The original Java checker has an early return in
case of `resultingDescriptor !is JavaClassConstructorDescriptor`.
It fires if the descriptor is
`TypeAliasConstructorDescriptor`, thus further
diagnostics are not reported.
2023-09-07 13:48:22 +00:00
Rustam Musin 1efa9abf57 Add missing space in GradleStyleMessagerRenderer.render()
In `GradleStyleMessagerRenderer.render` method, when there is `location` pointing to some file and coordinates `line:column = 0:0`, then a space between the location and the message was not printed.
#KT-61737 Fixed
2023-09-07 13:34:59 +00:00
strangepleasures 88453a05f1 KT-53551 KT-52213 KT-58476 Fix handling of suspend functional types with context receivers 2023-09-07 12:40:01 +00:00
Anton Bannykh 002cd011d4 [JS] add CLI test for KT-60531 2023-09-07 08:21:34 +00:00
Alexander.Likhachev 6eaccc997f [Build] Fix the typo junit jupyter -> jupiter 2023-09-06 22:47:34 +00:00
Alexander.Likhachev 6f96be0b76 [Build] Get rid of the testApiJUnit5 method
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Alexander.Likhachev 53fde520d5 [Build] Add jUnit dependencies in testApiJUnit5 to the implementation configuration
Adding these dependencies to the `api` configuration pollutes classpath for each dependant modules even if it doesn't need them. Instead, the dependencies should be declared more granularly if they're required
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Alexander.Likhachev 0ecbb64c64 [Build] Remove testApiJUnit5 parameters
Instead of declaring additional dependencies inside the method, declare them directly
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Alexander.Likhachev 7a1dc1f89b [Build] Do not add ij dependencies in testApiJUnit5
This is not needed since the dependencies are already declared as API dependencies in the relevant projects.
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Alexander.Likhachev ef0fb557a5 [Build] Split junit-jupiter into api and engine
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Alexander.Likhachev 357d12fc8e [Build] Move JUnit dependencies into the version catalog
The `kotlin-test` dependencies are left untouched as changing them affects publications, thus these versions are independent from the used inside our build
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Ilya Kirillov 190f7c4d30 [frontend] refactoring, reuse org.jetbrains.kotlin.resolve.multiplatform.isCompatibleOrWeakCompatible
to avoid code duplication
2023-09-06 16:30:28 +00:00
Ilya Kirillov 030250d387 [FIR] fix resolution ambiguities between weakly compatible expect and actual
There is a corresponding example inside the stdlib,
see `kotlin.text.startsWith`.

JVM and common counterpart are weakly-compatible
as the actual declaration has default arguments,
which results in `ExpectActualCompatibility.Incompatible.ActualFunctionWithDefaultParameters`

This commit allows such cases.

^KT-61732 fixed
2023-09-06 16:30:28 +00:00
Kirill Rakhman b41e5abcfa [FIR] Fix bounds check for inner classes of generic outer classes
#KT-61068 Fixed
#KT-35566
2023-09-06 15:15:07 +00:00
Roman Efremov 5e49b472f8 [FE, IR] Allow @ImplicitlyActualizedByJvmDeclaration to be set only on expect
@ImplicitlyActualizedByJvmDeclaration is the only one
OptionalExpectation annotation which works correctly when set only on
`expect`. All other (like @JvmName, @JsName) - not, so warning for them
must be reported.

^KT-61725 Fixed
2023-09-06 14:27:07 +00:00
Mikhail Glukhikh 056e644b6d FirBuiltinSymbolProvider: add a header comment describing built-ins
Related to KT-61330
2023-09-06 13:14:16 +00:00
Mikhail Glukhikh 4d9457862f K2: add sourceElement for binary Java classes
#KT-60555 Fixed
2023-09-06 13:14:16 +00:00
Kirill Rakhman 10e94f90ac [Tests] Trim contents before checking for FIR_IDENTICAL 2023-09-06 11:32:57 +00:00
Alexander Udalov 6b919e2593 K2: fix FirCompileKotlinAgainstCustomBinariesTest
Behavior of reporting UNRESOLVED_REFERENCE was changed in 10f7989af6.
2023-09-06 12:41:39 +02:00
Artem Kobzar bff433f4e9 [K/JS] Support eager initialization for per-file granularity 2023-09-06 09:27:28 +00:00
Dmitriy Novozhilov f203681ffa [FIR] Make extensionReceiver and dispatchReceiver nullable
Get rid of FirNoReceiverExpression

^KT-59650 Fixed
2023-09-06 09:25:22 +00:00
Kirill Rakhman 585c3fe4b5 [Tests] Add test for #KT-61717 2023-09-06 08:34:04 +00:00
Alexander Udalov fec2d063c1 K2: report PRE_RELEASE_CLASS on JVM
Note that 3 tests are still muted, but for another reason: for FIR
versions of the tests, we need to compile the "pre-release library" with
the next language version which is 2.1. But since currently
LanguageVersion.LATEST_STABLE is 1.9, the compiler refuses to read
metadata of version 2.1, regardless of its own language version. Which
is correct, but it leads to irrelevant errors in the test output -- the
ones about the incompatible metadata version, NOT about the
prereleaseness.

These 3 tests can be unmuted once the default language version is
switched to 2.0.

 #KT-60780 Fixed
2023-09-06 08:05:34 +00:00
Alexander Udalov 8738ffb84f K2: suppress exception when reading unsupported metadata
Before the change, the compiler threw exception in the unmuted tests,
because it tried to load metadata even though it had an unsupported
version. Use the same approach as in K1 (see
DeserializedDescriptorResolver).

Now the tests are unmuted, but note that test data differs from K1. K1
does not report errors related to the class `a.A` because it loads this
class as a _Java class_, so calling its constructor and methods somehow
works. This behavior is questionable since the compiler surely knows
that it is a Kotlin class, but with an unsupported metadata version.
Trying to interpret it as a Java class may lead to subtle problems. So
it's safer for now to avoid loading Kotlin classes with unsupported
metadata versions in K2.

 #KT-60795 Fixed
2023-09-06 08:05:34 +00:00
Alexander Udalov 8f720ad24b K2: support -Xskip-metadata-version-check
#KT-60795
2023-09-06 08:05:34 +00:00
Alexander Udalov 7d60b5df43 K2: report INCOMPATIBLE_CLASS in JVM
#KT-60795
2023-09-06 08:05:34 +00:00
Alexander Udalov db8fb30343 K2: minor cleanup in JvmClassFileBasedSymbolProvider 2023-09-06 08:05:34 +00:00
Alexander Udalov 1d5ade1166 K2: minor, remove misleading FirMemberDeclaration.containerSource
"Container source" means "the source of the container". So, if you
called this extension on a class (`FirClassLikeDeclaration`), it was
reasonable to assume that you would get the source of its _containing
class_, whereas the function actually returned the source of the class
itself.

Instead of inventing another name for this function, I've decided to
inline and remove it because it has only one usage.
2023-09-06 08:05:34 +00:00
Alexander Udalov 54a5f7d8f2 Remove unused test data on JS metadata version
Apparently these tests are no longer being run after a6d461dbe8.
2023-09-06 08:05:33 +00:00
Kirill Rakhman 393a5d6c14 [FIR] Fix IAE in TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM
IllegalArgumentException: class
org.jetbrains.kotlin.psi.KtLambdaArgument is not a subtype of class
org.jetbrains.kotlin.psi.KtExpression for factory
TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM
was reported when TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM was
reported on a FirLambdaArgumentExpression, report it on its
`expression` instead.

#KT-60380 Fixed
2023-09-06 07:38:34 +00:00
Ilmir Usmanov ae8b896c7b Minor. Add regression test for KT-59051
FIR2IR generates correct IR, unlike PSI2IR.
 #KT-59051 Fixed
2023-09-05 15:11:36 +00:00
Ilmir Usmanov 184b5cebe7 Minor. Add regression test for KT-60136
Spread operator works incorrectly in K1, but correctly in K2.
 #KT-60136 Fixed
2023-09-05 15:11:36 +00:00
Dmitriy Novozhilov 2d334c4e71 [Test] Merge multiple abstract legacy test runners into a single one
There was only one real inheritor of AbstractFirBaseDiagnosticTest,
  so there is no need in the whole hierarchy of abstract test runners

Also AbstractFirOldFrontendLightClassesTest is not intended to check any
  diagnostics or CFG dumps, so this logic was removed (they still can be
  checked using non-legacy AbstractFirDiagnosticTest from the main test
  infrastructure)
2023-09-05 14:59:36 +00:00
Dmitriy Novozhilov fa4c6d55c1 [FIR] Store mapped jvm declarations in session component, share it between MPP modules
^KT-61640 Fixed

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there is one test break in branch for KT-61637:
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.testJavaMethodWithTypeParameter
2023-09-05 14:43:43 +00:00
Dmitriy Novozhilov bb36beb364 [FIR] Share enhancedSymbolStorage between common and platform sessions
This is needed for two reasons:
1. common and platform modules are analyzed in the same setup with same
   dependencies and configurations, so the results of the enhancement for
   any function will be completely identical. So by sharing enhanced
   symbol storage, we avoid recomputation enhanced functions and improve
   performance
2. There is a goal to have some unique key for IR declarations in FIR2IR.
   For regular declarations, the key is just Fir symbol, and for fake-overrides
   it is a pair of original symbol and fake override owners lookup tag.
   But for enhanced functions the symbol is not unique, because we create
   different symbols for the same enhanced function for different modules.
   So this change fixes this problem

^KT-60397 Fixed

This change doesn't affect any tests in the moment, because it's part of
  bigger refactoring of proper storing IR declarations during FIR2IR
  conversion (KT-61637)

Without this change, there are some test breaks in branch for KT-61637:
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.testStarImportOfExpectEnumWithActualTypeAlias
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.DefaultArguments.testNestedEnumEntryValue
- FirPsiBlackBoxCodegenTestGenerated.Multiplatform.K2.Basic.testEnumEntryNameCall
2023-09-05 14:43:43 +00:00
Dmitrii Gridin bd10ee10fe [psi] avoid usage of SAFE_IDENTIFIER_FOR_NO_NAME
This name leads to inconsistency between FqName from stub and
FqName from ClassId.
The first one is `no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40`
but the second one is `<no name provided>`.
We can't just replace SAFE_IDENTIFIER_FOR_NO_NAME to NO_NAME_PROVIDED
due to many places with unsafe logic inside type mapping.

^KTIJ-26848 Fixed
2023-09-05 12:58:50 +00:00
Dmitrii Gridin ae02d78aff [PSI] ClassIdCalculator: cleanup code
^KTIJ-26848
^KTIJ-26896
2023-09-05 12:58:50 +00:00
Dmitrii Gridin 0701da6c59 [stub] simplify ClassId creation
We can create nested ClassId just from the parent stub instead of calculation by tree.
This commit simplified the complexity of ClassId building to liner.
Example:
```kotlin
package one
class A {
  class B {
    class C {
      class D
    }
  }
}
```
Previously, we had to create ClassId by traverse parents for each class.
Now we will visit each class only once.
It should improve performance and memory consumption during indexing.

^KTIJ-26848
2023-09-05 12:58:50 +00:00
Brian Norman f51b7faa1b [FIR] Only track assignment nodes for uncaught exception edges in CFG
UncaughtExceptionPath edges are used to influence smart-casting within
catch and finally blocks. Previously these edges were added from every
node which could throw an exception. But only assignment nodes influence
smart-casts by resetting inference back to some less specific type.
Therefore, instead of tracking every possible node which could throw an
exception - even though almost every statement node can - only add edges
from assignment nodes to catch and finally blocks. This fixes many
missing exception cases and also reduces the total number of incoming
edges to catch and finally blocks.

#KT-56872 Fixed
2023-09-05 11:59:13 +00:00
Vladimir Sukharev 2a4681b91d Adjust diagnostic tests for proper K1/N stdlib
^KT-58240
2023-09-05 11:42:46 +00:00
Vladimir Sukharev 3aa6c9e74d [K/N] Run irText tests for K1/Native
^KT-58240
2023-09-05 11:42:45 +00:00
Ivan Kylchik c2076a0227 [Native] Move hasNonConstInitializer from IrUtils2
This function could be useful for other backends.
2023-09-05 11:21:51 +00:00
Ivan Kylchik ddde95bd78 [Native] Move irByte from IrUtils2
We already have similar functions in `ExpressionHelpers`. Makes
sense to keep them together.
2023-09-05 11:21:51 +00:00
Ivan Kylchik 5cd96831dc [Native] Move isRestrictedSuspendFunction from IrUtils2
This function is also helpful for JVM backend.
2023-09-05 11:21:50 +00:00