Commit Graph

307 Commits

Author SHA1 Message Date
Kirill Rakhman 2f3293f99e [FIR] Skip redundant INAPPLICABLE_CANDIDATE on call with unresolved callable reference argument
A new resolution diagnostic UnsuccessfulCallableReferenceAtom is
introduced that is used in EagerResolveOfCallableReferences.
No diagnostic is reported on unresolved calls with this diagnostic
because

#KT-59856
2023-07-20 07:29:18 +00:00
Nikolay Lunyak d13e60aaec [FIR] Prevent loosing errors for synthetic outer calls
The error occurs when completing the
call for the outer synthetic call
`ACCEPT_SPECIFIC_TYPE`. The error
is saved into the CS of this outer
candidate, which leads to its
callable reference to be an error
reference, but since such calls are
not parts of the FIR tree, we never
collect such errors.

^Fixed KT-59233
2023-07-10 10:26:43 +00:00
Kirill Rakhman 5abab2197b [FIR] Adapt positioning of NO_VALUE_FOR_PARAMETER to match K1 2023-07-04 16:00:45 +00:00
Dmitriy Novozhilov 6c7eb0167c [FIR] Report errors about type arguments on resolved qualifiers
^KT-56186 Fixed
^KT-56187 Fixed
^KT-59553
2023-06-22 07:09:15 +00:00
Mikhail Zarechenskiy 060f3fa7c4 Extract diagnostics about class literals with empty LHS
^KT-59152
2023-06-19 15:21:32 +00:00
Mikhail Zarechenskiy 1153238fd7 Extract diagnostics about references to variables to a separate one
Note that I've left in FIR everything as is to avoid non-trivial
refactoring that is required right now to report more specific diagnostics

 ^KT-59152
2023-06-19 15:21:32 +00:00
Nikolay Lunyak 5daec16ce0 [FIR] Forbid creating abstract class instances via any qualified access
^KT-58938 Fixed
2023-06-07 16:45:28 +00:00
Kirill Rakhman 7f46225bed [FIR] Set correct constraint position for callable reference
This fixes a false positive resolution error for callable references
to functions with a type parameter that's annotated with
@OnlyInputTypes.

#KT-57994 Fixed
2023-04-24 14:04:50 +00:00
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
Nikita Bobko 8314812ef9 2/2 FirUnsupportedSyntheticCallableReferenceChecker: don't report error on FirJavaOverriddenSyntheticPropertySymbol
Meta issue: KT-8575
^KT-58061 Fixed
Review: https://jetbrains.team/p/kt/reviews/9677

This commit fixes an inconsistency between
FirUnsupportedSyntheticCallableReferenceChecker and
UnsupportedSyntheticCallableReferenceChecker

In K1 such properties were not considered synthetic and are called
JavaPropertyDescriptor. That's why we need to do an additional check in
K2 checker, while in K1 we didn't need to do it

Also see the previous commit for more related tests that already was
green without this fix but are related to KT-58061 problem
2023-04-19 14:33:45 +00:00
Nikita Bobko 11f376ae84 1/2 Covert FirUnsupportedSyntheticCallableReferenceChecker with more tests
Review: https://jetbrains.team/p/kt/reviews/9677

I'm going to fix KT-58061 in the next commit. Firstly, let's cover
FirUnsupportedSyntheticCallableReferenceChecker with more tests that
already pass, but are related to KT-58061 problem.
2023-04-19 14:33:45 +00:00
Nikita Bobko 5a96754aec Shift ReferencesToSyntheticJavaProperties feature release from 1.9 to 2.1
Other related tests:
- testGenericJavaProperty
- testFunInterfaceConstructorReference

Meta issue: KT-8575
Review: https://jetbrains.team/p/kt/reviews/9595

UnsupportedSyntheticCallableReferenceChecker only existed for K1,
because we wanted to release the feature for 1.9 and the feature should
have been working for K2 unconditionally. But since, we're postponing
the release until 2.1, we also need to port the checker from K1 to K2
2023-04-17 17:42:01 +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
Kirill Rakhman 471ecf62c8 [FIR] Fix UNRESOLVED_REFERENCE in callable reference to delegated var
#KT-57204 Fixed
2023-03-14 09:13:42 +00:00
Kirill Rakhman b2fbf8bed5 [FIR] Fix callable reference adaptation for overrides without defaults
Provide the correct scope to the argument mapping so that default values
in overridden functions are considered.

^KT-56864 Fixed
2023-03-09 08:26:16 +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 33dcbaac16 K2: Change resolution rules of when/if expressions with expected type
When expected type is known, use it as expected type for branch bodies.
While it indeed becomes different from the usual select call resolution,
where expected type is applied only after completion starts,
it helps to support, e.g. callable references resolution just as powerful
as it was in K1.

Also, in some cases where diagnostics have been changed, they become
a bit more helpful since they are reported closer
to the problematic places

cannotCastToFunction.kt test has been removed because it relied
on the case erroneously supported by the hack removed from
the FirCallResolver in this commit.

^KT-45989 Fixed
^KT-55936 Fixed
^KT-56445 Fixed
^KT-54709 Related
^KT-55931 Related
2023-02-15 08:13:46 +00:00
Denis.Zharkov a38040680c K2: Do not use KFunctionN as representation type for adapted references
Beside some corner cases, it's already prohibited in K1 because
adaptation have a bit strange nature
(they don't represent any existing real function exactly)

^KT-55137 Fixed
2023-02-15 08:13:45 +00:00
Denis.Zharkov dcdc48a233 K2: Support callable references adaptation on top-level
^KT-45989 In progress
^KT-54709 Related
^KT-55217 Fixed
2023-02-15 08:13:44 +00:00
Kirill Rakhman 1eb18f13bd FIR: Fix test data after making LHS of assignment an expression
KT-54648
2023-01-31 08:39:43 +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
Dmitriy Novozhilov bd3a28d04d [FE 1.0] Report INTEGER_OPERATOR_RESOLVE_WILL_CHANGE in missing cases
Covered places:
- local properties
- vars
- return positions of functions and lambdas

^KT-45970 Fixed
^KT-55358 Fixed
2022-12-09 15:10:03 +00:00
Mikhail Glukhikh 2a1a5c6936 EmptyIntersectionTypeChecker: drop questionable check of arguments
The situations with conflicting type arguments normally don't provoke
any runtime problems. Also, conflicts like A<T> VS A<SomeType> aren't
valid at all. Here we decided to remove them to avoid strange
and non-actionable warnings in user code.

#KT-54411 Fixed
2022-12-09 15:00:40 +00:00
Marco Pennekamp d4e6a4ad54 [FIR] KT-54978 Prohibit explicit type arguments in property accesses
- Add a checker which ensures that property accesses have no explicit
  type arguments. If an error on the property access's callee reference
  already exists, the new error is not reported in favor of the existing
  error, as the property access may have been intended to be a function
  call.
- `complicatedLTGT.fir.kt`: The underlying parser issue is not yet
  solved, which is why `x` is parsed as a property access with explicit
  type arguments.
- `reservedExpressionSyntax` tests: This new check makes a lot of the
  access expressions in these tests illegal, so valid lines have been
  added and invalid lines appropriately marked with
  `EXPLICIT_TYPE_ARGUMENTS_IN_PROPERTY_ACCESS` errors.

^KT-54978 fixed
2022-11-29 14:47:59 +00:00
Denis.Zharkov 2953e600ff K1: Deprecate incorrect callable references resolution behavior
^KT-54316 Related
^KT-54832 Fixed
2022-11-15 15:06:58 +00:00
Pavel Mikhailovskii f4bdf54601 KT-8575 Fix warnings for Java synthetic properties 2022-10-10 22:03:58 +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 32a73968de Stop tower resolve in K2 in more similar manner with K1 2022-07-27 15:29:41 +00:00
Victor Petukhov 42e71f8c53 Remove explicit enabling the new type inference from test data 2022-07-22 16:03:52 +00:00
Victor Petukhov 224beb24eb Remove explicit disabling the new type inference from test data 2022-07-22 16:03:51 +00:00
Mikhail Glukhikh d16e5e5e50 FIR: Support checking PRIVATE_TO_THIS visibility #KT-49875 Fixed 2022-07-15 07:57:41 +00:00
Victor Petukhov 0199c76c06 [FE 1.0] Check callable reference return type safety during resolution
^KT-51844
^KT-52503 Fixed
2022-05-27 13:56:34 +00:00
Ivan Kylchik 51ccc32a3f Update test data after introducing IntrinsicConstEvaluation annotation 2022-05-18 21:19:57 +03:00
Victor Petukhov 5bfe6cd20a [FE] Implement discussed rules to report empty intersection errors 2022-04-27 19:50:22 +00:00
Ivan Kochurkin c6f52893fb [FIR] Fix inconsistent RETURN_TYPE_MISMATCH and TYPE_MISMATCH reporting on functions and properties
^KT-51203 Fixed
2022-04-05 15:50: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 b327f5c731 Substitute type variables properly in ConeOverloadConflictResolver
#KT-46187 Fixed
2022-03-23 09:54:46 +00:00
Dmitriy Novozhilov ade2307345 [FIR] Fix exponential analysis of augmented array access calls
^KT-50861 Fixed
2022-03-11 15:36:05 +03:00
Ivan Kochurkin f751f13c4d [FIR] Fix incompatible KClass<Any> and callable reference Collection::class, ^KT-51272 Fixed 2022-02-23 14:21:59 +03:00
Ivan Kochurkin a0510f4a67 [FIR] Fixed Replace ConeTypeVariable on ConeTypeParameter ^KT-51017
in AbstractConeCallConflictResolver.computeParameterTypes
2022-02-07 17:21:59 +03:00
Denis.Zharkov adb9dfb256 FIR: Rework processing AugmentedArraySetCall
Previously (few commits earlier), it contained two versions
of receiver (lhs) generated separately for each desugaring version
that looked a bit redundant.

Now, at FIR building stage we just don't create desugaring sub-trees,
instead they are being built during bodies transformation and that seems
to be much convenient there, since we don't need to reverse-engineer
get-set-operator version to check if containing calls are successful
(as we just built those calls and retain them)

Semantically, this changes may only change how data flow works
for such statements (see changed compatibilityResolveWithVarargAndOperatorCall.kt)

^KT-50861 Relates
2022-02-01 13:12:49 +03:00
Mikhail Glukhikh e8be9d4861 FIR: support don't use builder inference if possible
In this commit we upgrade FIR builder inference logic from
the compiler version to 1.7. FIR-based compiler now works with
"don't use builder inference" flag always ON and supports switching
the flag "use builder inference only if needed". To do it,
ContraintSystemCompleter (FIR) and KotlinConstraintSystemCompleter (FE 1.0)
are made similar with extracting some common parts into
ConstraintSystemCompletionContext.

Test status: one BB test fails after this commit (KT-49285).
Also we have a crush in DFA logic in FIR bootstrap test and somehow
questionable behavior in FIR diagnostic test. However,
two BB tests were fixed, the 3rd case from KT-49925 were also fixed.

#KT-49925 Fixed
2022-01-20 23:46:36 +03:00
Ivan Kylchik 6fc56477bf Drop all tests that disable features for language version less than 3 2021-12-28 20:08:56 +03:00
Dmitriy Novozhilov f2c319c4ae [FIR] Add ability to safe proper ConeKotlinType in FirErrorTypeRef
This is needed for cases when some type ref is resolved to proper type
  but has some diagnostic (e.g. this type is invisible)
2021-11-26 11:26:16 +03: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
Ivan Kochurkin d0a4ca199d [FIR] Add UNCHECKED_CAST
Regenerate diagnostics code
2021-11-12 15:20:45 +03:00
Denis.Zharkov 6e15ee8fea FIR: Refine callable reference resolution in assignment position
synthetic_select<() -> T>(::foo) form allows to select better candidate
than synthetic_select(::foo) with expect type `() -> T`
2021-11-10 22:00:01 +03:00
Victor Petukhov 02d06b6390 Transform VisibilityError diagnostic for callable references to further report it on the corresponding argument of a base call
^KT-46437 Fixed
2021-10-26 19:37:57 +03:00
Victor Petukhov abd2507107 Don't discriminate generics during callable references resolution
^KT-49038 Fixed
2021-10-01 22:09:33 +03:00