Commit Graph

237 Commits

Author SHA1 Message Date
Roman Efremov 23ae617ea0 Fix inaccurate report of DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM
Add separate diagnostic for the case when it is reported on qualifiers.

^KT-64488
2024-02-27 11:22:35 +00:00
Roman Efremov 02b5fed389 Fix inaccurate report of DEPRECATED_ACCESS_TO_ENTRY_PROPERTY_FROM_ENUM
It can be reported not only from within the enum, but also from
top-level functions. Add separate diagnostic for such cases.

^KT-64488
2024-02-27 11:22:35 +00:00
Roman Efremov 34d87465ac [Test] Add test for Enum.entries shadowing when property is imported
This is similar to KT-64488 but without context receivers.
Warning message "access ... from within the enum" is also incorrect
here.

^KT-64488
2024-02-27 11:22:35 +00:00
Nikita Bobko da8a8cc492 Revert "K2/Java: add private enum constructor for MPP matching"
Review: https://jetbrains.team/p/kt/reviews/13368/timeline

This reverts commit 2cea2b9098.

Motivation:
KT-62961 was fixed independently by two different commits:
- ac3d8ad3ac
- 2cea2b9098

If possible, it's better not to introduce implicit declarations.
That's why it was agreed to keep
ac3d8ad3ac and revert
2cea2b9098
2023-12-05 17:49:18 +00:00
Mikhail Glukhikh 1260d03561 Drop erroneous FirJavaConstructorBuilder.visibility
Related to KT-62961
2023-11-28 13:30:26 +00:00
Mikhail Glukhikh 2cea2b9098 K2/Java: add private enum constructor for MPP matching
#KT-62961 Fixed
2023-11-28 13:30:26 +00:00
Stanislav Ruban 73aaa1ce28 [tests] Add code examples from exploration of KT-62239 2023-11-16 16:39:35 +00:00
Kirill Rakhman 44a4498ee5 [FIR] Report ABSTRACT_MEMBER_NOT_IMPLEMENTED_BY_ENUM_ENTRY on enum entries with initializer
#KT-59577 Fixed
2023-10-27 13:27:35 +00:00
Ilya Goncharov 065733e87c [FIR] Add UNINITIALIZED_ENUM_ENTRY on access qualifier of local enum
^KT-59967 fixed
2023-10-25 15:36:11 +00:00
Brian Norman e6669b51d4 [FIR] Check standalone companion object qualifiers are visible 2023-09-21 22:33:50 +00:00
Kirill Rakhman 7a65c36bfc [FIR] Add test for CLASS_CANNOT_BE_EXTENDED_DIRECTLY with typealias
#KT-61921
2023-09-18 12:13:02 +00:00
Mikhail Glukhikh 3ff2c7d6f7 K2: introduce custom Enum.entries migration checkers
Related to KT-56623, KT-56587
#KT-59344 Fixed
2023-08-31 13:29:02 +00:00
Mikhail Glukhikh e0d68fc93e K2: introduce FirEnumEntriesRedeclarationChecker (KT-59344) 2023-08-31 13:29:01 +00:00
Nikolay Lunyak e4246e8f51 [FIR] Support ENUM_CLASS_CONSTRUCTOR_CALL
^KT-59411 Fixed
2023-08-04 11:20:40 +00:00
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