Commit Graph

5932 Commits

Author SHA1 Message Date
Dmitrii Gridin dfdd86da1f [FIR] do not capture class context during class annotations processing
^KT-62587
2023-10-17 20:32:11 +00:00
Dmitrii Gridin b03e3f0b0d [LL FIR] pass correct context during class annotation arguments mapping
The root cause of the problem is that we visit class annotations more
accurately than in the regular compiler transformer, so we have
a difference: the compiler assumes that annotation processing
of the class is called already inside this class, so it should enable
CLASS_HEADER_ANNOTATIONS mode to not capture extra context.
But we in LL FIR do this out of the class, so such context switching
is redundant and results in cutting out the outer class context

^KT-62587 Fixed
2023-10-17 20:32:11 +00:00
Dmitrii Gridin bbd09c6272 [LL FIR] add tests for nested class as annotation argument
^KT-62587
2023-10-17 20:32:11 +00:00
Evgeniy.Zhelenskiy 5b4731a780 [FIR] Fix local typealias visibility resolution
#KT-60026
2023-10-17 12:48:04 +00:00
Dmitriy Novozhilov 3b6ad36af1 [Test] Update/unmute tests after previous fixes
It's hard to tell which exact commit fixed each test
2023-10-17 12:46:28 +00:00
Dmitriy Novozhilov c3f3a4192c [FIR] Check supertypes hierarchy for java classes during creation of synhtetic properies
^KT-62394 Fixed
2023-10-17 12:46:28 +00:00
Vladimir Sukharev 242c1cf5f0 [FIR] Fix disappeared REPEATED_ANNOTATION for dynamic types
https://youtrack.jetbrains.com/issue/KT-59916/K2-Disappeared-REPEATEDANNOTATION
FirAnnotationChecker does not detect repeated annotation on dynamic type, since FirTypeResolverImpl wrongly did not convert source annotations to attributes of ConeDynamicType.
This MR improves FirTypeResolverImpl to convert attributes of FirDynamicTypeRef to annotations and attach them to ConeDynamicType.

Merge-request: KT-MR-12551
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-17 10:18:36 +00:00
Mikhail Glukhikh fd057ac68a FE: Add two more tests around KT-59561 2023-10-17 06:49:38 +00:00
Mikhail Glukhikh 9f6abfc166 K2/MPP: treat Array<Some> & Array<out Some> as similar types in annotations
#KT-59561 Fixed
Related to KT-61100
2023-10-17 06:49:38 +00:00
Mikhail Glukhikh f085d0f660 K2: add reproduction of KT-61100 and KT-59561 2023-10-17 06:49:37 +00:00
Ivan Kochurkin 498f2e534a [FIR] Don't enhance Int and String Java final static fields
It's effectively a breaking change (^KT-62558)

K2 assigns flexible type to all static fields (from Java) and, for example,
`String? becomes String unlike K1. It affects IR signature generating.
That's why signature dump is disabled for some tests.

^KT-57811 Fixed
^KT-61786 Fixed
2023-10-16 17:16:56 +00:00
Alexander Udalov 2788dcb5ff K2: resolve remove(Int) clash in JavaOverrideChecker
In Kotlin subclasses of `MutableCollection<Int>`, the method
`remove(Int)` has its argument boxed, so that it wouldn't clash with the
method from `java.util.List`. So `JavaOverrideChecker` should understand
that a Java method `boolean remove(java.lang.Integer)` overrides it,
otherwise platform declaration clash was reported.

The code is adapted from `forceSingleValueParameterBoxing` in K1's
`methodSignatureMapping.kt`.

The test has been moved and adapted from diagnostic to codegen box
tests, to check correct backend execution + runtime.

 #KT-62316 Fixed
2023-10-16 11:26:58 +00:00
Roman Efremov 0fd700de21 [FIR] Fix case with lazy resolve in expect-actual annotation checker
Unresolved annotation arguments were treated as absent arguments,
which lead to false-positive reports.
Add assert and test for that and fix.

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00
Roman Efremov 4c75fb108f [Test] Add test for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT diagnostic
...when annotations arguments are lazily resolved.

MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Roman Efremov 423f4ca5f0 [FE, IR] Check compatibility of annotations set on type usages in expect and actual declarations
This includes checking of annotatins set on:

- value parameter types
- type parameter bound types
- extension functions receiver types
- function return types
- class super types

Fix in `defaultParams_inheritanceByDelegation_positive.kt`
is needed because of problem in resolution of implicit return types
(KT-62064), which leads to crash in annotation checker, because it
expects resolved return type.

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00
Roman Efremov cb8529d65b [Test] Add tests for annotations set on type usages in expect and
...actual declarations.

 MR: KT-MR-12245

^KT-60671
2023-10-16 10:48:08 +00:00
Vladimir Sukharev 16dfc6df71 [FIR] Missing NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE
^KT-59433 Fixed
2023-10-16 09:08:23 +00:00
Vladimir Sukharev da1fa8fce4 [FIR] Revert: Fix K2: Introduced AMBIGUOUS_ANONYMOUS_TYPE_INFERRED
This reverts commit d7adc0ce32.


Merge-request: KT-MR-12569
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-16 09:05:58 +00:00
Mikhail Glukhikh 0fb4c9b4fe FIR2IR: generate specific sources for property accessors
Related to KT-60111
2023-10-13 15:42:58 +00:00
Roman Efremov d09c3783fd [K2] Fix mistake in language feature name for
...`DEFAULT_ARGUMENTS_IN_EXPECT_ACTUALIZED_BY_FAKE_OVERRIDE`
diagnostic.

^KT-62036
2023-10-13 12:30:41 +00:00
Nikolay Lunyak e452113a7a [FIR] Fix missing INVISIBLE_REFERENCE on imports
^KT-59927 Fixed
2023-10-13 11:56:54 +00:00
Nikolay Lunyak 21cb5cf83a [FIR] Store the first file in data.state.classifierContainerFileMap
Note that this doesn't affect
multi-module configurations

^KT-59927
2023-10-13 11:56:54 +00:00
Nikolay Lunyak 41c3f98419 [FIR] Make resolution of classes in FirProvider more reasonable.
See the `privateInFile.fir.kt` test.
Type mismatches are simply confusing.

`inheritorOfExpectSealedClass.out`
reports unresolved reference probably
because now it resolves into the expect
declaration, rather than the actual one.
K1 doesn't report UNRESOLVED_REFERENCE
in this case. But this is red code
anyway. And this behavior still
depends on the order in which the compiler
receives both the declarations.

^KT-59927
^KT-62567
2023-10-13 11:56:54 +00:00
Nikolay Lunyak a9ceae9667 [FIR] Add the privateInFileInDifferentModule test
We only see the redeclaration
diagnostics on the declarations inside
the second file, because of
`FirRecorder::visitRegularClass`.
`data.state.classifierContainerFileMap`
references the last file, so
when checking the visibility of
the first `private class C { ... }`
(when collecting declarations that
conflict with the second `private class C`)
the provider returns the second file
instead of the first one, so the class
behaves as it is visible, and
`collectTopLevelConflict` returns in
this case.

As for why `INVISIBLE_*`s are reported
inside the first file: this is because
`data.state.classifierMap` stores the
last classifier it sees instead of
the first one.

^KT-62537
2023-10-13 11:56:54 +00:00
Ilya Goncharov 1fd9706f47 [K2] KT-60080 Fix packageFqn for property accessor symbol
^KT-60080 fixed
2023-10-12 17:44:47 +00:00
Roman Efremov a05b37c652 [K2] Support reporting of SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS
...on regular classes and enum entries.

^KT-59979 Fixed
2023-10-12 13:01:40 +00:00
Roman Efremov 32a87836c2 [Test] Improve test of SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS diagnostic
Add case where explicit primary constructor is present in expect,
so that SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR is not
reported.

^KT-59979
2023-10-12 13:01:40 +00:00
Nikolay Lunyak 54285736d0 [FIR] Don't miss diagnostics passed to @Suppress as names = []
In these cases we have a `FirVarargArgumentsExpression`
with a `FirNamedArgumentExpression` inside as its first
argument, which, in turn, has a `FirArrayLiteral`
argument.

^KT-62146 Fixed
2023-10-12 08:56:12 +00:00
Nikolay Lunyak 598b5dbdf4 [FIR] Reproduce KT-62146 2023-10-12 08:56:12 +00:00
Alejandro Serrano Mena 166b99181b [Test] Ensure that properties cannot be used as operators
In some cases the combination of property + invoke was incorrectly allowed

^KT-62349
2023-10-12 08:32:17 +00:00
Anastasia.Nekrasova e3bab4a7da [K2] Prohibit smart casts for 'expect' properties
^KT-61340
2023-10-11 17:05:29 +00:00
Roman Efremov e4ea733482 [K2] Support reporting of EXPECTED_ENUM_ENTRY_WITH_BODY
Test for the case when enum entry has constructor call but doesn't have
body already exist in
`compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt`.

^KT-59978 Fixed
2023-10-11 15:04:02 +00:00
Nikolay Lunyak df6f51b49f [FIR] Ignore the operator keyword when checking conflicting overloads
^KT-59880
2023-10-11 08:54:09 +00:00
Nikolay Lunyak 09436d0480 [FIR] Report conflicts for constructors of top-level classes
^KT-59880
2023-10-11 08:54:09 +00:00
Nikolay Lunyak bc2eb546b4 [FIR] Report conflicts for data class generated members
^KT-59880
2023-10-11 08:54:09 +00:00
Nikolay Lunyak afc22728fa [FIR] Don't miss annotations while generating augmented assignments
^KT-62473 Fixed
2023-10-11 08:33:05 +00:00
Nikolay Lunyak 54e9cafc73 [FIR] Reproduce KT-62473 2023-10-11 08:33:05 +00:00
Vladimir Sukharev 69d2b94a68 [FIR] Fix Disappeared NULLABLE_TYPE_IN_CLASS_LITERAL_LHS
^KT-59970 Fixed
2023-10-10 18:23:19 +00:00
Vladimir Sukharev 1c395ef0df [FIR-TEST] Remove accidentally committed testfiles 2023-10-10 18:22:41 +00:00
Mikhail Glukhikh 9d3bf69212 Raw FIR/LT: use similar sources for delegated constructor calls
After this commit all IR source range tests behave in the same way
for FIR/PSI and FIR/LT, test data is now consistent
2023-10-10 13:38:52 +00:00
Brian Norman ccda8ae23d [FIR] Comparison to String implies smart cast to String
When the left-hand side of an equality comparison is known to be a
String, and the equality condition resolves to true, then the right-hand
side can be smart-cast to a String as well. This was working for String
expressions on the left-hand side but not for String constants.

^KT-57513 Fixed
2023-10-10 11:20:40 +00:00
Brian Norman 79303ab2db [FIR] Ignore anonymous functions during annotation argument phase
Anonymous functions (lambdas) are not allowed as annotation arguments.
However, because it is still possible to parse code written this way, it
must be handled without exception. So ignore these expressions when
processing annotation arguments.

#KT-59565 Fixed
2023-10-09 20:03:33 +00:00
Nikolay Lunyak 2e7dcd6096 [FIR] Require overrides to have matching isSuspend flag value
^KT-57100 Fixed
2023-10-09 06:55:43 +00:00
Nikolay Lunyak 4e58715760 [FIR] Check conflicting overloads via scopes
Scopes may return private symbols from
supertypes, they should not clash with
symbols from the current class.

For example, see:
`FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.FakeOverride#testPrivateFakeOverrides1`

Lombok shouldn't generate functions if the
user has defined explicit ones.

In K1 generated functions are not really
added to the declared members scope.

^KT-61243 Fixed
2023-10-09 06:55:43 +00:00
Nikolay Lunyak 973248f432 [FIR] Reproduce KT-57100 2023-10-09 06:55:43 +00:00
Dmitrii Gridin f124ba627d [FIR] implicit type: avoid redundant property and function transformations
This is a contract violation – we can touch only bodies during this phase

^KT-56551
2023-10-06 14:13:37 +00:00
Dmitrii Gridin 889c210576 [FIR] add more tests for implicit type phase
These tests demonstrate the implicit type phase problem - annotations
are also resolved, although they should not

^KT-56551
2023-10-06 14:13:36 +00:00
Ivan Kochurkin 89fe73f6f4 [FIR] Consider expect default function parameters in FirSuperCallWithDefaultsChecker
^KT-61572 Fixed
2023-10-06 12:29:01 +00:00
Evgeniy.Zhelenskiy feed3a57d0 [FIR] Report wrong modifiers in function type arguments and types of value parameters
#KT-59955
2023-10-06 12:22:57 +00:00
Dmitrii Gridin 96c45c74e8 [LL FIR] improve contract violation checks
Add check into LLFirModuleLazyDeclarationResolver to die fast
and avoid StackOverflowError for jumping phases

^KT-56551
^KT-57802
^KT-57811
2023-10-06 11:40:05 +00:00