Commit Graph

82 Commits

Author SHA1 Message Date
Dmitrii Gridin 72def186a3 [LL FIR] rework transformers, so transformers resolve only a specific set of declarations
The change is needed for the parallel resolution (^KT-55750), so we can resolve the declaration
under a lock that is specific to this declaration.
Previously, if LL FIR was resolving some FirClass, LL FIR  resolved all its children too, and it had no control over what parts of the FIR tree were modified.
The same applied to the designation path, sometimes the classes on the designation path
might be unexpectedly (and without lock) modified.

This commit introduces LLFirResolveTarget, which specifies which exact declarations should be resolved during the lazy resolution of the declaration.
All elements outside the declarations specified for resolve in LLFirResolveTarget, should not be modified.

The logic of lazy transformers is the following:
- Go to target declaration collecting all scopes from the file and containing classes
- Resolve only declarations that are specified by the LLFirResolveTarget, performing the resolve under a separate lock for each declaration

^KT-56543
^KT-57619 Fixed
2023-04-19 20:12:38 +00:00
Nikolay Lunyak 8d04ab3142 [FIR] Ignore nullability in the definition of "identity-less"
The definition of a "builtin" already
ignores nullability.

`Int? === String?` must trigger a
diagnostic by design.
2023-04-19 16:05:19 +00:00
Nikolay Lunyak f0720c1d12 [FIR] Fix K2 behavior according to RULES1
The compiler should only report diagnostics for
comparisons over builtins and identity-less types,
other incompatibilities should be reported
via inspections.

It's ok that in `equalityChecksOnIntegerTypes`
instead of `EQUALITY_NOT_APPLICABLE_WARNING` we get
`EQUALITY_NOT_APPLICABLE`, because
`ProperEqualityChecksInBuilderInferenceCalls`
is already active by default.

This change also replaces the notion of a representative superclass
with the least upper bound.
This makes complex types like
intersection/flexible transparent to
RULES1-based compatibility checks.
One way to look at it is to think
that this is an automatic way of handling
type parameters: automatic picking of
"interesting" bounds, and checking them against one another.

Note that `TypeIntersector.intersectTypes`
for `Int` and `T` where `T` is a type parameter
may return both `{Int & T}` or `null`
depending on `T`-s bounds. At the same time,
for type parameters `T` and `K` it will
always return `{T & K}`.

`ConeTypeIntersector.intersectTypes`, on the
other hand, will always return `{Int & T}`
irrespectively of the bounds. Meaning, the two
intersectors differ in corner cases.

`lowerBoundIfFlexible` call in `isLiterallyTypeParameter` is backed by
the `equalityOfFlexibleTypeParameters` test.

^KT-35134 #fixed-in-k2
^KT-22499 #fixed-in-k2
^KT-46383 #fixed-in-k2
2023-03-31 15:01:50 +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
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00
Mikhail Zarechenskiy c586d7a03a Use more specific error for secondary constructor bodies in inline classes
- Also, this error allows IDE to provide quick-fix that changes language
 version in a project that simplifies the adoption
 - There is no point in
 changing K2 part as there this feature will be enabled by default

 ^KT-56224 Fixed
2023-02-03 13:38:31 +00:00
Dmitriy Novozhilov 88efa6bfb6 Update tests after switching to LV 1.9 2023-01-30 09:29:57 +00:00
Ilya Kirillov 3afb93ca31 [FIR] fix resolve contract violation from ConeTypeContext.getValueClassProperties
^KT-54890
2023-01-13 21:32:52 +00:00
Ilya Kirillov 1bbcae5ed2 [FIR] fix resolve contract violation from scopes
We cannot call lazy resolve to STATUS phase from scopes as scopes may be accessed on a STATUS phase or earlier

^KT-54890
^KTIJ-23587 fixed
2023-01-13 21:32:51 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Evgeniy.Zhelenskiy 9f01ccc304 [IR] Support user-defined equals for MFVC
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:36 +00:00
Evgeniy.Zhelenskiy 6107caa8e2 [FE1.0, FIR] Support secondary constructors for Value Classes
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-11-30 18:55:35 +00:00
Vladislav Grechko cd6e865fb3 Improve support of 'lateinit' modifier
- Allow 'lateinit' for inline classes which underlying type
is suitable for 'lateinit'

- K2: report all problems related to 'lateinit' modifier

^KT-55052: Fixed
2022-11-24 19:47:21 +00:00
vladislav.grechko 36b8ba8df3 Improve support of custom equals in inline classes
- Ensure that typed equals parameter's type is a star projection of
  corresponding inline class

- Make possible to declare typed equals that returns 'Nothing'

- Forbid type parameters in typed equals operator declaration

^KT-54909 fixed
^KT-54910 fixed
2022-11-17 15:35:14 +01:00
Nikolay Lunyak 267ce1d892 [FIR] KT-54220: Don't crash on unsigned integers when no stdlib present
^KT-54220 Fixed
2022-11-15 09:02:33 +02:00
vladislav.grechko 817afcd4af KT-MR-7307 review fixes 2022-10-13 15:19:10 +00:00
vladislav.grechko e0c8142106 Support of custom 'equals' and 'hashCode' in inline classes
'equals' from any made available for overriding in inline classes
'typed' equals made available for definition in inline classes
'typed' equals definition made compulsory if 'untyped' is overridden
'operator' keyword is allowed in 'typed' equals definition

^KT-24874: Fixed
2022-10-10 16:52:34 +00:00
Ilya Chernikov 854127bcc8 Fix testdata after switching Kotlin to version 1.8
(see the previous commit with the same title for details)
2022-07-01 14:31:45 +02:00
Ilya Chernikov bc1e3667ff Fix testdata after switching Kotlin to version 1.8
the corresponding features - GenericInlineClassParameter && DataObjects
- were turned on in 1.8 right after the last check build, therefore the
discrepancy went unnoticed
2022-06-30 16:34:14 +00:00
Ivan Kylchik 51ccc32a3f Update test data after introducing IntrinsicConstEvaluation annotation 2022-05-18 21:19:57 +03:00
Evgeniy.Zhelenskiy 28bf83ceac [IR] Unite inline class and multi-field value class representation
#KT-1179
2022-03-24 11:38:43 +00:00
Victor Petukhov 27fa632630 [FE 1.0] Update test data with new error type representation 2022-03-23 21:13:33 +00:00
Mikhail Glukhikh 53d6ac24e5 Switch kotlin version to 1.7
* Change 1.6 to 1.7 constants
* Fix SAFE_CALL_WILL_CHANGE_NULLABILITY for testData
* Change EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_WARNING to EXPOSED_PROPERTY_TYPE_IN_CONSTRUCTOR_ERROR
* Change NON_EXHAUSTIVE_WHEN_STATEMENT to NO_ELSE_IN_WHEN
* Fix testData for SafeCallsAreAlwaysNullable
* Change T -> T & Any in test dumps
* Change INVALID_CHARACTERS_NATIVE_WARNING -> INVALID_CHARACTERS_NATIVE_ERROR
* TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_WARNING -> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR
2022-02-25 11:46:27 +00:00
Ilmir Usmanov 909b455758 Support generic underlying type of inline class in FIR
#KT-32162
2022-02-15 08:11:09 +01:00
Ilmir Usmanov 9060168542 Support generic underlying type of inline class
Use upper bound in JVM representation.
 #KT-32162
2022-02-15 08:11:08 +01:00
Ilmir Usmanov f95cba0ec3 Support delegation by interface for inline classes in FIR
#KT-27435 Fixed
2021-12-08 00:11:55 +01:00
Ilmir Usmanov bb53ba4a2e Enable delegation by interface for inline classes in old FE
#KT-27435
2021-12-08 00:11:54 +01:00
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00
zhelenskiy c1dc1f7e33 Diagnostics renamed
Signed-off-by: zhelenskiy <zhelenskiy2000@yandex.ru>
2021-11-13 12:38:45 +01:00
zhelenskiy ea10b4a781 Synchronizing by values and primitives is forbidden
Signed-off-by: zhelenskiy <zhelenskiy2000@yandex.ru>
2021-10-29 18:50:30 +02:00
Ivan Kochurkin 2c1c24c042 [FIR] Implement WRONG_MODIFIER_CONTAINING_DECLARATION, DEPRECATED_MODIFIER_CONTAINING_DECLARATION 2021-08-13 18:32:28 +03:00
Ivan Kochurkin cd6384eb20 [FIR] Fix handling of WRONG_MODIFIER_TARGET
Implement DEPRECATED_MODIFIER, DEPRECATED_MODIFIER_FOR_TARGET, REDUNDANT_MODIFIER_FOR_TARGET
2021-08-13 18:32:27 +03:00
Tianyu Geng 7bb81ef157 FIR: add equality call checker
Added checker for FirEqualityOperatorCall. It's surfaced as one of the
following diagnostics depending on the PSI structure and types under
comparison:

* INCOMPATIBLE_TYPES(_WARNING)
* EQUALITY_NOT_APPLICABLE(_WARNING)
* INCOMPATIBLE_ENUM_COMPARISON_ERROR

Comparing with FE1.0, the current implementation is more conservative
and only highlights error if the types are known to follow certain
contracts with `equals` method. Otherwise, the checker reports warnings
instead.

However, the current checker is more strict in the following situations:
1. it now rejects incompatible enum types like `Enum<E1>` and
  `Enum<E2>`, which was previously accepted
2. it now rejects incompatible class types like `Class<String>` and
  `Class<Int>`, which was previously accepted
3. the check now takes smart cast into consideration, so
  `if (x is String) x == 3` is now rejected
2021-05-06 17:50:32 +03:00
Ilmir Usmanov 64abb2501f Minor. Add FIR_IDENTICAL directive 2021-03-15 06:19:22 +01:00
Ilmir Usmanov d3b42709fd Revert "Value Classes: Forbid var properties with value class receivers"
This reverts commit f43899086a.
2021-03-12 17:51:24 +01:00
Mikhail Glukhikh 15c3269e38 FIR: don't report error on inline nested classes 2021-03-06 09:22:35 +03:00
eugenpolytechnic f6e564ffa6 FIR: introduce inline classes checks 2021-03-06 09:22:34 +03:00
Ilmir Usmanov 62123d72e2 IC: Add inline class -> @JvmInline value class warning 2021-02-25 16:06:47 +01:00
Tianyu Geng bdeecfc188 FIR: check multiple vararg param and forbidden vararg type 2021-02-24 13:50:46 +03:00
Tianyu Geng 6b453d9b23 FIR: implement checker for open members
Specifically,

1. NON_FINAL_MEMBER_IN_FINAL_CLASS
2. NON_FINAL_MEMBER_IN_OBJECT
2021-02-19 10:17:18 +03:00
Dmitriy Novozhilov f3a8fcaea6 [FE] Make constructors of sealed classes protected instead of internal 2021-02-12 13:36:38 +03:00
Dmitriy Novozhilov f14bd87ecc [Test] Update testdata of diagnostic tests during to change language to 1.5
Mostly this commit contains changes of descriptor dump of sealed classes
  tests according to changed visibility of sealed class constructor
2021-01-28 13:19:24 +03:00
Jinseong Jeon 8b4f2b269c FIR checker: introduce PARAMETER_* positioning strategies
and use them to add support diagnostics:
ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE
USELESS_VARARG_ON_PARAMETER
2021-01-27 19:46:05 +03:00
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00
Ilmir Usmanov 775d610045 Value classes: Forbid any identity equality check on value class
#KT-31130 Fixed
2020-12-10 08:24:48 +01:00
Ilmir Usmanov f43899086a Value Classes: Forbid var properties with value class receivers 2020-12-04 09:45:56 +01:00
Ilmir Usmanov 0d55c9108d IC: Forbid inner classes inside inline classes
#KT-43067 Fixed
2020-12-04 05:45:53 +01:00
Ilmir Usmanov 15c325cf10 Value classes: Allow nested inline classes 2020-12-04 05:45:51 +01:00
Ilmir Usmanov c62093f54c IC mangling: Change mangling rules
1. Use 'x' for each parameter, which is not an inline class, every
possible clash is handled by signature rather than name. This change
makes more API changes binary-compatible. So, the changes are in line
with the vision of inline classes are value classes, like primitives.

2. Take return type into account when mangling a function if the return
type is inline class. Otherwise, boxing bridge will not be generated,
which leads to CCE at runtime.
2020-11-19 17:39:24 +01:00
Ilmir Usmanov 326768e8b5 Minor. Update test data 2020-11-04 00:20:39 +01:00