Commit Graph

106467 Commits

Author SHA1 Message Date
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
Sergej Jaskiewicz a5b5492b2d [IR generator] Simplify configuration of visitor parents
Don't specify a visitor parent manually for each IR node,
use an algorithm instead.
2023-11-24 17:29:58 +00:00
Sergej Jaskiewicz 62d32471e1 [FIR generator] Extract BaseTransformerTypeFinder into the common module
We want to use it in other tree generators.
2023-11-24 17:29:58 +00:00
Anastasia.Nekrasova 7787b53b4a [K2] Disappeared UNSUPPORTED
Forbid callable reference to coroutineContext

^KT-59881
2023-11-24 15:59:04 +00:00
Alexander Udalov daac8603d0 Fir2Ir: build fake overrides for abstract methods from Any
This call to isAbstractMethodOfAny was in Fir2IrLazyClass since its
inception in 0622be14a5, and there's no explanation why this was
necessary. Removing it does not seem to break anything, but fixes the
case when IrFakeOverrideRebuilder is enabled and when Java base class
declares an abstract equals/hashCode/toString which is not overridden in
the Kotlin subclass.

 #KT-63443 Fixed
2023-11-24 14:48:10 +00:00
Alexander Udalov b63a780e15 Build: update kotlinx-metadata-jvm to 0.7.0 2023-11-24 14:03:21 +00:00
Roman Golyshev 644e29a2ea Revert "KT-61890 [AA] Use ContextCollector in KtFirScopeProvider"
This reverts commit 47a00bf9

See KTIJ-27918
2023-11-24 11:21:15 +00:00
Ilya Goncharov f9ffe67430 [Gradle, JS] Add comment why we use project.provider and not use single 2023-11-24 11:17:49 +00:00
Philip Wedemann 1dbb227de2 KT-63544: Fix Gradle CC problem in KotlinJsIrLink 2023-11-24 11:17:49 +00:00
Kirill Rakhman 31256e259e [FIR] Fix lower bound of flexible type variable not becoming DNN in warning-severity case
The bug was introduced as part of the implementation for Java
nullability warnings.

#KT-58933 Fixed
2023-11-24 11:00:10 +00:00
Kirill Rakhman 711e7ce8d7 [FIR] Add regression test for overriding Java with DNN without annotations
#KT-58933 Related
2023-11-24 11:00:10 +00:00
Kirill Rakhman ad3da48f55 [FIR] Remove redundant special cases from FirStandardOverrideChecker
AbstractTypeChecker.equalTypes already handles the same special cases.
2023-11-24 11:00:10 +00:00
Kirill Rakhman 4882ac6599 [FIR] Fix duplicate WRONG_NULLABILITY_FOR_JAVA_OVERRIDE
Also, the test shows a missing warning in K1 which is present in K2.

#KT-63600 Fixed
#KT-63599
#KT-63745
#KT-63746
2023-11-24 11:00:10 +00:00
Artem Olkov 54c2339dfb [Analysis API] [Test Infra] move (de)compilation services
move (de)compilation services from static dependencies into DI
This is done for allowing different (de)compile strategies in the future


Merge-request: KT-MR-13213
Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
2023-11-24 10:58:49 +00:00
Ilya Gorbunov 88bbe8d92d [stdlib] Enable explicit API mode 2023-11-24 01:45:45 +00:00
Ivan Kochurkin 115d685d91 [FIR] Fix ambiguity of Throws and other std annotations importing
Including `SharedImmutable` and `ThreadLocal`

Simplify code, remove `DefaultImportPriority.KOTLIN_THROWS`

Introduce `FirNativeClassMapper`
2023-11-23 23:51:23 +00:00
Pavel Punegov adf4f823ae [K/N][perf] Fix the fallback framework path in swift performance
After bootstrap update and the change that added /usr subdir to
absoluteTargetToolchain


Merge-request: KT-MR-13212
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
2023-11-23 18:37:18 +00:00
Svyatoslav Scherbina e5ae32c37a Native: remove bitcode embedding from tests
Xcode 14 deprecates bitcode embedding, and Xcode 15 removes support
for it. Therefore, testing bitcode embedding in Kotlin doesn't make
much sense.

This commit removes most of test code that enables bitcode.

^KT-61875
2023-11-23 18:36:59 +00:00
Ilya Goncharov 957d3c5610 [Gradle, JS] Use binaries for wasi with KotlinJsIrCompilation 2023-11-23 18:36:39 +00:00
Vladimir Sukharev 5ea59f57d6 [K/N] Verbose possible cinterop tool exceptions
^KT-59288
2023-11-23 18:36:00 +00:00
Yahor Berdnikau b000b3a90b [Gradle] Drop usage of non-LTS JDK versions in integration tests 2023-11-23 18:28:10 +00:00
Dmitrii Gridin 224b21b177 [LL FIR] LLFirTargetResolver: rename resolveDependencyTarget to resolveDependencies
^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin 5183019cb8 [LL FIR] resolve class before constructor
This is required to have stable resolution order to avoid concurrent
modifications and correct resolution context.
This also fixes KT-63700 as a super call expands only during body
resolution in the case of secondary constructor

^KT-63042
^KT-63700 Fixed
2023-11-23 15:55:07 +00:00
Dmitrii Gridin e3d91741ca [LL FIR] resolve class before delegate field
This is required to have stable resolution order to avoid concurrent
modifications and correct resolution context.
E.g., this commit fixes the resolution behavior of delegate field for
ANNOTATION_ARGUMENTS phase – now annotation argument resolves in the
correct scope

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin 5a54520723 [FIR] add missed transformations for type annotations inside FirField
This issue doesn't affect the compiler because delegate field shares
annotation instance with the containing class, so it will be resolved
before field anyway.
In Low Level FIR we didn't notice this issue because we don't have
isResolved checks for type annotations (KT-63681)

^KT-63042
^KT-63681
2023-11-23 15:55:07 +00:00
Dmitrii Gridin 38c959ba5a [LL FIR] resolve original declarations before fake
This is required to have stable resolution order to avoid concurrent
modifications and correct resolution context.
E.g., this commit fixes the resolution behavior of fake override for
ANNOTATION_ARGUMENTS phase – now annotation argument resolves correctly.

We shouldn't do additional checks in the case of fake declaration
because they should be done on the original side

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin ab26a02d19 [LL FIR] resolve generated property before copy
This is required to have stable resolution order to avoid concurrent
modifications

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin c31d860f10 [FIR] LightTreeRawFirBuilder: add copyWithNewSourceKind for generated copy
This is done for consistency

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin 9d72c1c370 [FIR] builder: drop unused forcedElementSourceKind
There was only one usage by withDefaultSourceElementKind that was
dropped in the previous commit

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin 6c1f5b7a74 [FIR] PsiRawFirBuilder: reuse type for copy from generated property
Previously, this call was required to avoid sharing to have independent
instances with their own resolution cycle. Now we will have stable
order (in the next commit), so it is possible to share instances.
Also, this change makes the logic consistency with Light Tree

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin a79cef08b5 [LL FIR] resolve generated property before componentN
This is required to have stable resolution order to avoid concurrent
modifications.
Another point here – status phase logic for componentN function is
located in the corresponding property resolution

^KT-63042
2023-11-23 15:55:07 +00:00
Dmitrii Gridin 5fa516e010 [LL FIR] resolve constructor parameter before generated property
This is required to have stable resolution order to avoid concurrent
modifications

^KT-63042
2023-11-23 15:55:06 +00:00
Dmitrii Gridin 6ecaccbcfe [FIR] PsiRawFirBuilder: reuse type for property from constructor parameter
Previously, this call was required to avoid sharing to have independent
instances with their own resolution cycle. Now we will have stable
order (in the next commit), so it is possible to share instances.
Also, this change makes the logic consistency with Light Tree

^KT-63042
2023-11-23 15:55:06 +00:00
Dmitrii Gridin 8dacd41818 [LL FIR] introduce lazy resolve tests for type annotations
From one side to check how annotation propagation works and from another
side to cover scenarios with lazy resolution from type position as it is
a valid case of usage in Analysis API (KtFirAnnotationListForType)

^KT-63042
2023-11-23 15:55:06 +00:00
Dmitrii Gridin 689fe28efa [FIR] FirScriptSymbol: add stable toString
It will be used in tests

^KT-63042
2023-11-23 15:55:06 +00:00