Commit Graph

223 Commits

Author SHA1 Message Date
Mikhail Glukhikh 15b070b494 K2: don't resolve callable reference to enum entries #KT-59611 Fixed 2023-07-06 15:06:31 +00:00
Kirill Rakhman e7c213e06e [FIR] Report separate error for delegated constructor call to interface
#KT-59216 Fixed
2023-07-04 16:00:45 +00:00
Kirill Rakhman 6d1d6e48c1 [FIR] Rename qualifiedAccessOrAssignmentsOrAnnotationCalls to callsOrAssignments and add delegated constructor calls 2023-07-04 16:00:45 +00:00
Mikhail Glukhikh 4b7ab54d95 FE: fix test data after commit clash 2023-06-21 19:25:14 +02:00
Mikhail Glukhikh 78f4d399d4 FE: add test to ensure Java entries static field is resolved normally 2023-06-21 13:08:01 +00:00
Mikhail Glukhikh 905e1dcd3b K2: introduce prioritized enum entries resolve by a 2.1 feature
Related to KT-48872
2023-06-21 13:08:01 +00:00
Mikhail Glukhikh b92f1e2036 K2: de-prioritize access to Enum.entries properly #KT-57954 Fixed 2023-06-21 13:08:00 +00:00
Mikhail Glukhikh 978d52d05b K2: render additionally *s for static references
This commit allows to distinguish static VS non-static things
inside FIR_DUMP, e.g. static synthetic Enum.entries with
enum entry Enum.entries
2023-06-21 13:08:00 +00:00
Mikhail Glukhikh 70899d492d K2: reproduce KT-57954 and reorganize tests around enum entries warnings
In particular, here we add FIR_DUMP to all enum entries tests with
some deprecation diagnostics and the feature on, and remove all txt-files
2023-06-21 13:08:00 +00:00
Brian Norman 8091aebbc7 [FIR] Create checker for simple enum entries with missing overrides
Complex enum entries (those with bodies) with missing overrides
are covered by an existing checker that checks all types of classes. But
simple enum entries (those without bodies) were not covered and require
a separate checker for missing overrides.

#KT-58637 Fixed
2023-05-29 16:34:44 +00:00
Vsevolod Tolstopyatov 5b474bc5d3 Stabilize EnumEntries stdlib signature
* Also, mention implementation details of EnumEntries to enable safe uses of a 'EnumEntries' as a set
* Fix testdata for opt-in marker in enum entries

^KT-58548 fixed

Merge-request: KT-MR-10037
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2023-05-11 09:18:44 +00:00
Dmitrii Gridin 093695962a [FIR] hacky fix lazy resolve contract violation for deprecation of enum entries
Enum entries can be used as types in Kotlin (even it's a compilation error)
To use the classifier as a type, we need to find if it's hidden or not.
The deprecations for classes are calculated on COMPILER_REQUIRED_ANNOTATION phase, and that's okay as it goes before the TYPES phase.
For enum entries, the deprecations are calculated on TYPES phase which goes on TYPES phase.
This is incorrect as we cannot jump from lower phase to upper phase

The hack ignores such deprecation search for enum entires.

Test: org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.Tests.testEnumEntryAsType

^KT-57648
^KT-56543
2023-04-19 20:12:36 +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
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
Denis.Zharkov fe5adab652 K2: Avoid inference diagnostics when arguments are already error typed
For example, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER

It became especially relevant after 0e84bf2053
that together with later commits bring a lot of unnecessary
NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER diagnostic
2023-02-15 08:13:41 +00:00
Anna Kozlova e5b96561e0 [FIR] skip implicit call to enum constructor if super type call exists
otherwise, reference to the super type would be resolved even when it's not
e.g. for interface constructor
^ KTIJ-24437
2023-01-27 08:20:07 +00:00
Mikhail Glukhikh 41966a745e Enum entries: add new tests with language feature ON & fix checker 2023-01-24 12:46:00 +00:00
Mikhail Glukhikh c534c54a1c FE: use WITH_STDLIB directive for Enum.entries tests 2023-01-24 12:46:00 +00:00
Mikhail Glukhikh 565adf3075 K1: don't filter Enum.entries in tower to report error later
After this commit we:
- preserve Enum.entries synthetic property in tower even in case the bound feature is OFF
- report an error on Enum.entries call in specific checker if the feature is OFF
- give this synthetic property lower priority, no matter feature ON or OFF

#KT-55251 Fixed
2023-01-24 12:45:59 +00:00
Mikhail Glukhikh 793df6234e FE: add test for KT-55251 2023-01-24 12:45:59 +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
Mikhail Zarechenskiy dc9193893e Add a test to check Java behavior with entries members
Note that there is a questionable behavior that will be fixed later.

 Right now it's not fully clear because for the same situation in Kotlin, the compiler reports warnings at declaration-site and it's not possible to do so for Java

 ^KT-53153
2023-01-04 13:17:11 +00:00
Mikhail Zarechenskiy 3cdbb4876f Add a warning for conflicting entries member
^KT-53153
2023-01-04 13:17:11 +00:00
Mikhail Zarechenskiy cf4b415a20 Add a warning for name shadowing case with Enum.entries
^KT-53153
2023-01-04 13:17:11 +00:00
Mikhail Zarechenskiy c70a1b1884 Add a warning for a custom Enum.entries entry
^KT-53153
2023-01-04 13:17:10 +00:00
Mikhail Zarechenskiy 989fc886e1 Add a warning for a user-defined entries property call
^KT-53153
2023-01-04 13:17:10 +00:00
Mikhail Zarechenskiy 695a538529 Move test about Enum.entries to a more specific folder 2023-01-04 13:17:10 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Ivan Kochurkin 8883de3f00 [FIR] Don't resolve Enum.declaringClass and Enum.getDeclaringClass
^KT-53946 Fixed
2022-11-23 18:29:29 +00:00
Nikolay Lunyak fcd3e4f4c5 [FIR JS] KT-51740: Alter positioning of NO_VALUE_FOR_PARAMETER 2022-09-30 21:39:20 +03:00
Mikhail Glukhikh 769a2ca9b1 K1: report ENUM_DECLARING_CLASS_DEPRECATED on enum entry properly
#KT-53807 Fixed
2022-09-12 10:45:23 +00:00
Mikhail Glukhikh fb1c80a7c9 K2: discriminate synthetic 'Enum.entries' during resolve 2022-08-19 10:08:11 +00:00
Mikhail Glukhikh 68ca453467 K2: don't report REDECLARATION on Enum.entries 2022-08-19 10:08:10 +00:00
Mikhail Glukhikh 730de8fd7c K1/K2: add test for enum class with 'entries' entry 2022-08-19 10:08:09 +00:00
Ivan Kylchik 51ccc32a3f Update test data after introducing IntrinsicConstEvaluation annotation 2022-05-18 21:19:57 +03:00
Victor Petukhov 27fa632630 [FE 1.0] Update test data with new error type representation 2022-03-23 21:13:33 +00:00
Vladimir Dolzhenko 918a91dbdf Escape special names with backticks in test data
#KT-51248
2022-02-10 21:20:47 +00:00
Mikhail Glukhikh fd3d86eddf FE 1.0: introduce deprecation for Enum.declaringClass (KT-49653) 2022-01-27 17:27:40 +03:00
Mikhail Glukhikh 983fa4c8c7 FIR: add temporary access to Enum.getDeclaringClass (see KT-49653) 2022-01-27 17:27:39 +03:00
Mikhail Glukhikh c2ab09fa84 Add test for KT-49653 2022-01-27 17:27:38 +03:00
Denis.Zharkov a0a57581ec FIR: Do not add alias for variables with explicit type 2021-10-20 22:05:24 +03: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 06ee84f809 FIR checker: report AMBIGUOUS_SUPER 2021-08-10 19:36:44 +03:00
Tianyu Geng c7272f6986 FIR checker: SENSELESS_(COMPARISON|NULL_IN_WHEN)
Currently DFA does not set "definitely equal to null" for access to variables that got assigned `null`. For example, FIR should mark the following line as SENSELESS_COMPARISON due to `s = null` above.
 https://github.com/JetBrains/kotlin/blob/d1531f9cdd5852352c0133198706125dc63b6007/compiler/testData/diagnostics/tests/smartCasts/alwaysNull.fir.kt#L6

The problem is at https://github.com/JetBrains/kotlin/blob/7e9f27436a77de1c76e3705da7aa1fbe8938336b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt#L1104

For null assignment, ideally the type should be `Nothing?`. This is
addressed in a followup commit instead.
2021-08-06 22:57:16 +03:00
Tianyu Geng e242ad955b FIR: tolerate comparison of an intersection of incompatible types
Previously, if user compares an `it<String, Int>` with `String`, the
checker reports it since the flattened types `[String, Int, Int]` are
incompatible. But technically, before flattening, the intersection type
actually contain the other side, so they should really be compatible.
2021-08-06 22:57:11 +03:00
Tianyu Geng a8e379a025 FIR: Fix positioning of ENUM_ENTRY_AS_TYPE
The current SELECTOR_BY_QUALIFIED positioning strategy is closely
related what should be done here. But it only works on qualified access
expressions. This change also makes it work for type references.
2021-07-22 20:39:56 +03:00
Tianyu Geng c648356887 FIR: report ENUM_ENTRY_AS_TYPE and IS_ENUM_TYPE
These two diagnostics are similar: both are reported on type references
to enum entries. But `IS_ENUM_TYPE` is reported if the type ref is an
operand of `is` operator. To pass along this contextual information, a
boolean is added to FirSpecificTypeResolverTransformer.
2021-07-22 20:39:56 +03:00
Dmitriy Novozhilov 7b5a5f5682 [FE 1.0] Report USELESS_IS_CHECK if is expression is always false
^KT-47684 Fixed
2021-07-13 10:35:01 +03:00
Ivan Kochurkin c3a6ba52f6 [FIR] Implement CLASS_CANNOT_BE_EXTENDED_DIRECTLY 2021-06-29 02:00:10 +03:00