Commit Graph

106501 Commits

Author SHA1 Message Date
Roman Efremov 4aaf290c99 [FIR] Fix incorrect matching of nested classes when actualized via typealias
There are still some places in `.fir.kt` where false-positive reports
remained. This is because of IR checker, which will be fixed in next
commit.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov a768ece70d [Tests] Add tests for other checkers having same problem with
...nested classes marching.

^KT-31636
2023-11-27 18:23:42 +00:00
Roman Efremov bfc775faf5 [Tests] Create test for nested classes matching when actualized via typealias
^KT-31636
2023-11-27 18:23:42 +00:00
Svyatoslav Kuzmich 6b6353f3b9 [Wasm] Add external file checker to K2
#KT-56849
2023-11-27 16:55:04 +00:00
Svyatoslav Kuzmich 7687b86654 [Wasm] Add JsModule checker to K2
#KT-56849
2023-11-27 16:55:04 +00:00
Sebastian Sellmair 977d1c0e41 [K/N] Implement objc export header test: functionWithErrorType 2023-11-27 16:39:15 +00:00
Sebastian Sellmair 04df33eec1 [K/N] Implement ObjCExportNamerTest and ObjCExportMapperTest
... to provide simple and quick validation
for their corresponding entities.

Those tests can also act as convenient entry points
for debugging.
2023-11-27 16:39:15 +00:00
Stanislav Ruban 269b60b420 [tests] Add a test case for KT-61978
^KT-61978 Obsolete
2023-11-27 15:50:46 +00:00
Ilya Gorbunov 28c1049518 [stdlib] KT-55619 provide samples and extend documentation for String.format 2023-11-27 15:04:51 +00:00
Alexander Korepanov b1465fbfb8 [JS FIR] Enable warnings and infos for JS FIR tests 2023-11-27 14:31:31 +00:00
Alexander Korepanov 862be5a787 [JS FIR] Fix FIR NON_EXPORTABLE_TYPE diagnostic bugs
- use a declaration source if a parameter source is null;
 - ignore constructor return type to avoid
   double-checking of the class itself;
 - ignore constructor type parameters
   obtained from the class declaration;
 - ignore enum entries property (it is not checked in K1 at all);
 - fix exportability check for function types;

 ^KT-63089 Fixed
2023-11-27 14:31:30 +00:00
Artem Kobzar 6615b77213 [K/JS] Rework symbol hash calculation to make IC works with @JsExport and @JsName changes 2023-11-27 13:49:56 +00:00
Leonid Startsev f7d87f6d70 Use type parameters' source information for kotlinx.serialization diagnostics
To be more consistent with K1, certain diagnostics should be reported
not on the whole properties' types, but on type arguments inside them.

Note that there is still a difference with K2 because K2 reports on a type argument
including its annotations, while K1 used KtTypeReference.typeElement.

IMO, K2 conveys the same or better meaning here, so I am willing to leave this
difference instead of providing PositioningStrategy.

#KT-53861 Fixed
2023-11-27 13:32:44 +00:00
Dmitriy Novozhilov a22a254c1e [Test] Fix passing useIrFakeOverrideBuilder flag in tests 2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov 039baf95fc [Test] Add empty platform module for MPP diagnostic test with only one module
After previous commits IrActualizer runs only there are at least two modules
  in backend input. So to check diagnostics from Actualizer all tests
  should contain at least two modules

Diagnostics in test `extendExpectedClassWithAbstractMember.kt` were
  changed because there is an exception from IrActualizer caused by
  errors from frontend (`ABSTRACT_METHOD_NOT_IMPLEMENTED`), which is
  swallowed by this kind of tests
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov 62d269b3b9 [AA] Use convertToIrAndActualize in KtFirCompilerFacility
It was the last place that manually called parts of fir2ir
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov ffe5b4c40d [Test] Update some IR dumps after previous changes
Now IR dump handlers receiver actualized IR with removed expected
  declarations, so corresponding tests should be updated accordingly
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov 48c3313e67 [Test] Inline processAllIrModuleFragments utility
After previous changes IR output artifact contains only one IrModuleFragment
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov 06af6adf4f [Test] Unify all fir2ir facades for non-jvm platforms
Setup of fir2ir for JS, Native and Wasm is very similar, so it makes
  sense to extract all common parts of it into common base facade
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov e38b25c278 [FIR2IR] Make convertAndActualize method the only entrypoint to fir2ir
Fir2Ir conversion consists of multiple steps with complex logic (like
  conversion of each module, actualization, plugins application, constant
  evaluation), and to ensure that they all are executed correctly it's
  convenient to have the single entry point for all this machinery
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov 075010b14e [Test] Get rid of some properties in IrBackendInput
`fir2IrComponents`, `irActualizerResult` and `dependentIrModuleFragments`
  were used in `IrActualizerAndPluginsFacade`, which was removed in the
  previous commit
2023-11-27 10:17:54 +00:00
Dmitriy Novozhilov 1303a33bea [Test] Get rid of IrActualizerAndPluginsFacade
IR actualization and IR plugins will be moved into base Fir2Ir facades
  in the following commits, so this facade is not needed anymore

It was easier and cleanlier to remove this facade first and only after
  that modify base facades
2023-11-27 10:17:54 +00:00
Sebastian Sellmair ddd97e84b9 [K/N] Implement lightweight tests for ObjC header generation 2023-11-27 09:08:54 +00:00
Kirill Rakhman 06811dfc2f [FIR] Add enum entry to body resolve context containers
This fixes processing of annotations on enum entries.
Before, the check in BodyResolveContext.forAnnotation would set the
tower data mode to CLASS_HEADER_ANNOTATIONS because no containers were
present.
This would lead to some tower data elements like nested classifiers
missing, which would lead to false positive unresolved references.

#KT-63761 Fixed
2023-11-27 09:00:17 +00:00
Anton Lakotka bb5e219c1d [Gradle] Explain reason for (isCanBeResolved && isCanBeConsumed) check 2023-11-26 18:47:29 +01:00
Anton Lakotka 7673434ccd [Gradle] Keep "-publishable" configurations as dependencyScope
As they would clash with the ones that is intended to be consumed as
project dependencies. It will not be compatible with future Gradle
versions. This should be fixed with KT-49919

^KT-60879
2023-11-26 18:47:29 +01:00
Anton Lakotka e73441843b [Gradle] Don't make native compilation api configuration resolvable
Instead, create a resolvableDetached configuration for that purpose.
Changing configuration roles is deprecated since Gradle 8.2

^KT-60879
2023-11-26 18:47:29 +01:00
Anton Lakotka 5d46e45da7 [Gradle] Fix tests for Gradle 8.2 compatibility
* Dependency scope configurations can't have attributes
* ConfigurationInternal.path is removed

^KT-60879
2023-11-26 18:47:29 +01:00
Anton Lakotka 2ab30d8880 [Gradle] Add role-based configuration method factories
Starting from Gradle 8.2 there is deprecation diagnostic that
disallows changing configuration roles after creation.

With Gradle 8.4 there is an Incubating API that introduces
role factories for Configuration. For consistency reasons names that
introduced in this commit match the names that Gradle introduces in 8.4
version.

^KT-60879
2023-11-26 18:47:29 +01:00
Abduqodiri Qurbonzoda e94b247835 Introduce Common StringBuilder.append/insert(Byte/Short) extensions #KT-63341 2023-11-26 02:48:19 +02:00
Abduqodiri Qurbonzoda db6a662631 Remove Common StringBuilder.append/insert(Byte/Short) members #KT-63341 2023-11-26 02:48:18 +02:00
Aleksei.Cherepanov c002af6365 Make plugin classpath serialization path agnostic
This is needed for correct usage of portable caches

^KT-63799 Fixed
2023-11-25 10:46:49 +00:00
Aleksei.Cherepanov ea85b30f88 Make CompilerSettings open to add listeners on IJ side
Workspace Model will return a copy of CompilerSettings instead of reference to the original one. Thats why we need to add listeners on it on IJ side

Relates to KTIJ-24647
2023-11-24 22:58:13 +00:00
Artem Kobzar 55d41db2ce [K/JS] Include jsFirEs6Test into jsFirCompilerTest tests 2023-11-24 22:09:43 +00:00
Mikhail Glukhikh e391e68ea3 K2: drop TypeParameterAsCallable check for reified in ::class
Related to KT-63377
2023-11-24 21:28:16 +00:00
Mikhail Glukhikh 83cfcc30c6 K2: handle type parameter vs nested class conflict in body resolve properly
This commit does two things:
- prioritize type parameter scopes against static scopes in body resolve
(effectively it's a revert of KT-58028 fix)
- consider type parameters as inapplicable callable, so during callable
resolve we can go up the tower and still resolve to static scope

This allows both KT-58028 and KT-63377 to work properly
#KT-63377 Fixed
2023-11-24 21:28:16 +00:00
Mikhail Glukhikh 4e938d852c K2: add some more tests around KT-63377 and KT-58028 2023-11-24 21:28:16 +00:00
Mikhail Glukhikh 99234ef1c5 K2: reproduce KT-63377 (+ consider some more cases) 2023-11-24 21:28:16 +00:00
Alexander Udalov 2d76c7b05d Generators: reduce verbosity when logging which files are generated
It made it a bit difficult to see which tests were affected when running
generateTests.
2023-11-24 19:48:09 +00:00
Nikita Bobko 6f17022449 [FIR] Cleanup: extract reportClassScopesIncompatibility into its own function
Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:49 +00:00
Nikita Bobko 7166adb179 [FIR, IR] Convert FirDefaultArgumentsInExpectActualizedByFakeOverrideChecker into ExpectActualCheckingCompatibility
FirDefaultArgumentsInExpectActualizedByFakeOverrideChecker is an adhoc
checker which can be converted to ExpectActualCheckingCompatibility to
reuse common expect-actual checking infrastructure.

^KT-62913 Fixed
Review: https://jetbrains.team/p/kt/reviews/13094/timeline

Tests that were broken by one of my previous commits are now fixed:
- actualFakeOverride_paramsAreCompatibleViaSharedMethodWithDefaultParams.kt
- inheritedJavaMembers.kt

DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE diagnostic
disappeared in delegation.fir.kt because only one
AbstractExpectActualChecker incompatibility can be reported at a time
(DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE is now reported
not by adhoc checker but by common AbstractExpectActualChecker). It
would be nice to report both of them, but it's a separate issue KT-62631

delegation2 test makes sure that
DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE is reported when
NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS is fixed
2023-11-24 18:02:49 +00:00
Nikita Bobko c8a9928624 [FIR] Deduplicate isFakeOverride
Reuse isFakeOverride from ExpectActualMatchingContext. It does the same
thing

Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:48 +00:00
Nikita Bobko 5b72c127bd [FIR, IR] Commonize isFakeOverride check for AbstractExpectActualAnnotationMatchChecker
This commit fixes fakeOverrides.fir.kt test that got broken in the
previous commit

Previously isFakeOverride was only checked on IR backend. Now this check
is moved to AbstractExpectActualAnnotationMatchChecker which is used by
both: frontend and backend. That's why frontend no longer reports false
positive ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT

Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:48 +00:00
Nikita Bobko e6bfcc7c65 [FIR] 2/2 update testData
This tests started failing after the previous commit. I extract this
change into a separate commit to make it obvious that appeared
diagnostics is not an expected behavior. I will fix these tests in the
following commits

Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:47 +00:00
Nikita Bobko a1ce8ac175 [FIR] 1/2 match and check expect fake-overrides vs actuals
^KT-63550 Fixed
Review: https://jetbrains.team/p/kt/reviews/13094/timeline

Now it's required to create a new ScopeSession when searching for expect
members for actuals. If you keep reusing actualScopeSession then members
declared in platform may "slip into" the search results, resulting an
incorrect expect for actual (e.g. it happens in
supertypeIsExpectActual_covariantOverrideOfInjectedFromSuper_transitiveSubstitutionFakeOverride.fir.kt)

I suppose that it always has been a bug that we reused
actualScopeSession because we were mixing actualScopeSession and
expect FirSession (which is a bad idea), but we simply didn't have cases
where this bug could be observed. Now after we started matching
fake-overrides, we have such cases.

But creating a new ScopeSession every time is a suboptimal solution. We
need to design a scope caching KT-63773
2023-11-24 18:02:47 +00:00
Nikita Bobko 5aa0475aa7 [KMP] Fix incorrect transitiveSuperclassActualization_java.kt test
Review: https://jetbrains.team/p/kt/reviews/13094

I made the test to look like transitiveSuperclassActualization.kt

`actual typealias A = A_J` is incorrect because `A` isn't expect

If I kept the test "as it's", then it would become red once KT-63550 is
fixed
2023-11-24 18:02:47 +00:00
Nikita Bobko 216006c504 [FIR] NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS: report both mismatches and incompatibilites
This commit is a preparation step for KT-59887. For now,
expectActualInlineClass.fir.kt became slightly more verbose. Once is
KT-59887 fixed, the verbosity will go away. Because we won't report
incompatibilites mismatches for ACTUAL_MISSING declarations

Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:46 +00:00
Nikita Bobko 93cf68a08d [IR] IrExpectActualAnnotationMatchingChecker: add elaboration comment
Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:46 +00:00
Nikita Bobko 584c353a44 [FIR, IR] shouldCheckAbsenceOfDefaultParamsInActual: update comment
Fixing KT-61105 won't help.
Review: https://jetbrains.team/p/kt/reviews/13094/timeline
2023-11-24 18:02:45 +00:00
Sergej Jaskiewicz 4307e76f15 [FIR/IR generator] Remove visitSuperTypeByDefault from visitor printers
This property is FIR-specific, no need to use it in the generic printer.
2023-11-24 17:29:58 +00:00