Commit Graph

7842 Commits

Author SHA1 Message Date
Kirill Rakhman 03fc0fd381 [FIR] Remove FirLambdaArgumentExpression
It's not really necessary if the information about if the lambda was a
trailing lambda can be directly saved in FirAnonymousFunctionExpression.

Removing the FIR node uncovered a couple of bugs
(UNINITIALIZED_ENUM_ENTRY, ERROR_IN_CONTRACT_DESCRIPTION) that were
caused by assuming that a lambda is always a trailing lambda.

#KT-66124
2024-03-13 17:05:48 +00:00
Mikhail Glukhikh f656a9fdc6 Migrate some KT-65789 & KT-58920 tests on using take<ExpectedType>(arg) 2024-03-13 14:57:34 +00:00
Mikhail Glukhikh 0f53ee64d6 K2: make qualifier & classifier the same tower level
#KT-65789 Fixed
#KT-38031 Fixed
2024-03-13 14:57:34 +00:00
Mikhail Glukhikh d6e67e43f9 K1/K2: add a test for KT-62866 2024-03-13 14:57:34 +00:00
Mikhail Glukhikh 3b9e08d6b8 K1/K2: reproduce KT-65789 2024-03-13 14:57:33 +00:00
Roman Efremov 284d5437e5 [FIR] Don't transform call arguments during TYPES phase
Instead, it should happen during BODY_RESOLVE phase.

This fixes KT-66150. The problem was, that `super<B>.f()` expression
in delegated constructor call was transformed during TYPES phase,
and type transformer has no special logic for allowing bare types in
super qualifiers, like the one in expressions transformer (see
`org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirExpressionsResolveTransformer.transformSuperReceiver`).
As a result, `B` without type argument leads to
WrongNumberOfTypeArgumentsError.
It looks incorrect that expressions in constructor call resolved
during TYPES phase, so skipping transformation of
argument list seems like the best solution here.

^KT-66150 Fixed
2024-03-13 14:31:14 +00:00
Roman Efremov c4f89ab32e [Test] Add test reproducing incorrect error in K2 about super qualifier
...with type arguments.
Also, add lazy resolve test to check the subsequent changes are correct.

^KT-66150
2024-03-13 14:31:14 +00:00
Kirill Rakhman 43a08068fc [Tests] Add regression tests for KT-32754
#KT-32754 Fixed
2024-03-13 12:39:54 +00:00
Alexander Udalov 55f9f74d5c Tests: do not report backend diagnostics if there's frontend error
In most affected tests, the backend diagnostic such as "conflicting JVM
signature" or "accidental override" is directly caused by some already
existing error reported by frontend, so it doesn't make sense to check
backend diagnostics there.

Tests where that was not the case were moved/copied to
`testsWithJvmBackend`.
2024-03-13 08:38:15 +00:00
Alexander Udalov dca6c21d7f Tests: remove duplicateJvmSignature diagnostic tests
All of these tests were actually copied to `testsWithJvmBackend` in
866f188120, but it's unclear why they were copied instead of moved. The
test runner for `testsWithJvmBackend` correctly runs the compiler
pipeline and obtains errors reported by the backend, as opposed to the
common diagnostic tests which have a very custom code, using parts of
the old JVM backend, to obtain these diagnostics.
2024-03-13 08:38:15 +00:00
Alexander Udalov 6ed06f4dac Tests: minor, move diagnostic test missingNames.kt
Looks like it was placed in the `duplicateJvmSignature` directory by
mistake.
2024-03-13 08:38:14 +00:00
Alexander Udalov 5be1ff1d5f Tests: minor, remove obsolete diagnostic tests
- `require.kt` was added to check JVM accidental override diagnostic
  when using the "traits with required classes" feature, which was
  removed a long time ago.
- `withErrorTypes.kt` was testing conflicting JVM declarations error (a
  backend diagnostic) in presence of error types -- not very useful
  scenario because the backend is not run when there's a frontend error.
2024-03-13 08:38:14 +00:00
Nikolay Lunyak d3dfbec01a [FIR] Report warnings for inconsistent visibilities of accessors
K1 didn't report diagnostics for accessors
of intersection overrides, so this change
prevents a BC.

^KT-66046 Fixed
2024-03-12 16:35:05 +00:00
Nikolay Lunyak 7ecbaf7d1e [FIR] Calculate property setters visibilities for intersections properly
Basically, just calculate them the same
way it's done for other members.

`chooseIntersectionVisibilityForSymbolsOrNull`
is named like this to prevent a JVM clash.

^KT-66046 Fixed
2024-03-12 16:35:05 +00:00
Nikolay Lunyak b7926b68ab [FIR] Fix sources of intersection override properties's accessors
^KT-66046
2024-03-12 16:35:05 +00:00
Nikolay Lunyak daa6e03e3b [FIR] Reproduce KT-66046
^KT-66046
2024-03-12 16:35:05 +00:00
Mikhail Glukhikh 0b34d66b87 Revert "FIR: Report CAPTURED_VAL_INITIALIZATION if initialization is done"
This reverts commit 1c4023fda5.

#KT-64854 Submitted
#KT-59906 Submitted
2024-03-12 15:58:34 +00:00
Mikhail Glukhikh d897bfbcad Fix tests after a semantically conflicting merge of KT-50008 and KT-65596 2024-03-12 14:54:10 +00:00
Brian Norman c6c0abae82 [FIR] Create test case to validate KT-56988 is working as expected
^KT-56988 Fixed
2024-03-12 14:48:39 +00:00
Kirill Rakhman 0889770ccd [FIR] Fix scope of Java classes that inherit multiple properties with the same name
Use the receiver and context receiver types in addition to the property
name as cache keys for the synthetic property generation.
Also, fix logic that searches for accessor overrides by comparing
receiver and context receiver types.
Finally, let synthetic properties delegate their receiverParameter and
contextReceivers to their accessors.

#KT-65464 Fixed
#KT-66195
2024-03-12 10:29:45 +00:00
Kirill Rakhman 89ecb92551 [FIR] Support deferred return type computation for synthetic properties
#KT-66048 Fixed
2024-03-12 10:29:45 +00:00
Kirill Rakhman 973e337bf5 [FIR] Enhance getter overrides based on overridden properties
The following tests are failing with exceptions and will be fixed in the
following commits

j+k/testKjkPropertyAndExtensionProperty.kt
j+k/testKjkImplicitReturnType.kt

#KT-62118 Fixed
2024-03-12 10:29:45 +00:00
Kirill Rakhman 885ba11d97 [FIR] Defer computation of enhanced return type when overridden has implicit return type
#KT-66048
2024-03-12 10:29:45 +00:00
Kirill Rakhman 888cac6fc0 [Tests] Reproduce #KT-66048 2024-03-12 10:29:45 +00:00
Kirill Rakhman 29a9d3cdd9 [FIR] Fix copy paste error in receiver enhancement 2024-03-12 10:29:44 +00:00
Vladimir Sukharev aa1cce78c3 [FIR] Incorrect warnings about inline function impact
^KT-65959 Fixed
2024-03-12 10:26:23 +00:00
Denis.Zharkov 232c3aeadc K2: Fix PCLA breaking change when using a bare type on a type variable
See the change at docs/fir/pcla.md and the kdoc
at `getAndSemiFixCurrentResultIfTypeVariable` for clarification

^KT-64840 Fixed
2024-03-12 10:22:11 +00:00
Denis.Zharkov 141be17b4b K2: Add some more tests showing the state for KT-64840
lambdaParameterForBareTypeEarlyFixationAffectsBehavior.kt
should show in the future commits how early variable fixation
necessary for bare type information might affect inference results

^KT-64840 Related
2024-03-12 10:22:11 +00:00
Ilmir Usmanov 1c4023fda5 FIR: Report CAPTURED_VAL_INITIALIZATION if initialization is done
outside of constructor.

In other words, when EXACTLY_ONCE lambda initializes non-static final
field of a class, the lambda has to be inlined, otherwise, backend
generated separate function of separate class for the lambda,
which lead to exception at runtime.

 #KT-64854 Fixed
 #KT-59906 Fixed
2024-03-12 00:42:07 +00:00
Nikita Bobko 989ec97bb0 [FIR] Make FirNotImplementedOverrideChecker to run only for non-expect classes or in metadata compilation
^KT-64187 Fixed
Review: https://jetbrains.team/p/kt/reviews/14807

I also checked that IDE sets metadataCompilation to `true` (Actually, it
looks like IDE performs analysis two times with the flag having
different values, but whatever, maybe it's even better this way)
2024-03-11 18:07:52 +00:00
Nikita Bobko 9d566465e6 [test] Run checkers in metadata-like style to see what diagnostics metadata compilation omits
Review: https://jetbrains.team/p/kt/reviews/14807

Technically, *.ll.kt should have been covering that. But I see that
there slight differences
2024-03-11 18:07:52 +00:00
Mikhail Glukhikh c4bcdc42c1 K2: don't count use-sites of Java type parameter with nullable bounds as not null 2024-03-11 18:05:04 +00:00
Mikhail Glukhikh d353fd400d K1/K2: add a test for KT-50008 2024-03-11 18:05:04 +00:00
Mikhail Glukhikh 633e96b966 K1/K2: add test for Future.get case 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh f597c02327 K1/K2: extend the test for KT-65184 with the case suggested by Simon 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 266669272d Rename/move/mark the test for KT-65184 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 98e4c64360 K1/K2: add more tests around intellij.vcs.git example 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh d04625666a K2: don't approximate captured types in ResultTypeResolver in certain cases
To be more precises, ResultTypeResolver for K2 now searches for
similar LOWER/UPPER constraints pair based on the same flexible type,
like LOWER(CapturedType&Any..CapturedType?) and UPPER(CapturedType!).
If such a pair is found, the CapturedType is not approximated.
This is done to avoid a big difference between this case and
completely same constraints, like LOWER(CapturedType!) and
UPPER(CapturedType!). In this case we squash them to EQUAL(CapturedType!)
even before ResultTypeResolver, and captured types which is got from
an EQUAL constraint are not approximated even before this commit.

This commit fixes back a case from KT-50134 and a problem with intellij.vcs.git

#KT-65596 Fixed
2024-03-11 13:38:05 +00:00
Mikhail Glukhikh c966533d73 K2: reproduce a problem from intellij.vcs.git 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh e701a16460 Fix of jspecify test data
In a1.bar<T?> now we have effectively T! bound instead,
so a diagnostic disappears here
2024-03-11 13:38:05 +00:00
vladislav.grechko 8a6467e524 [FIR] Add tests for KT-65184 to confirm its proper work
#KT-65184 Fixed
2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 78b6432ced K2: don't make T = Type! substitutions for constructors, including SAM
Without this commit we get some ABI changes and it looks bad.

Related to KT-65596
2024-03-11 13:38:05 +00:00
Denis.Zharkov 81414d758d K2: repeat K1 representation for flexible type parameters
This commit changes the behavior of KT-59138 effectively declining it in 2.0.
However, we plan to implement KT-59138 behavior under a feature
flag in 2.0 (see KT-66447), and switch this feature on version 2.x.

Also, this commit implements the LC resolution about postponing
KT-57014 change. We don't have KT-57014 described behavior in 2.0 anymore.
However, we plan to implement a deprecation warning here, see KT-65578.

After this commit, 6 diagnostic tests become incorrectly broken:
- 5 tests from PurelyImplementedCollection group
- a test platformTypes/nullableTypeArgument.kt

This commit also breaks currently fixed-in-k2 KT-50134
(it is fixed again in the following commits),
as well as KT-58933 (it will remain not fixed till we enable KT-59138
behavior again).

#KT-65596 In Progress
#KT-57014 In Progress
#KT-58933 Submitted
2024-03-11 13:38:05 +00:00
Mikhail Glukhikh db173b8ac5 K1/K2: add test for Comparator.comparing situation from intellij 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 993509c057 K1/K2: add test for streams situation from intellij 2024-03-11 13:38:05 +00:00
Mikhail Glukhikh 6e1b6427ab K1/K2: add a test confirming current behavior of KT-57014 case 2024-03-11 13:38:05 +00:00
Igor Yakovlev 324d079111 [WasmJs] Prohibit external classes to be a storage of an associated objects
Fix #KT-65355
2024-03-09 10:40:46 +01:00
Pavel Kunyavskiy 1222ef7fac [IrFakeOverrideBuilder] Do not compute signatures in Fir2IR
No one need them, while it requires significant time usage

^KT-66281
^KT-66441 Fixed
2024-03-08 21:36:59 +00:00
Nikolay Lunyak 405852980d [FIR] Prohibit is-checks and casts for unrelated nullable types
This decision was made after a discussion
in Slack.
2024-03-08 15:37:45 +00:00
Nikolay Lunyak 4c0ec0fae4 [FIR] Remove redundant checks from isUpcast() and isExactTypeCast()
`T.() -> R` and `(T) -> R` should only be
different for resolution, but casts are only
about typechecking. Values of either of
these types can always be put into variables
of the other type.
2024-03-08 15:37:45 +00:00