Commit Graph

87 Commits

Author SHA1 Message Date
Denis.Zharkov d7399ed1cf K2: Avoid losing diagnostics for synthetic calls
Some of the changed tests may duplicate other existing diagnostics,
but that should not be reason not to report them at all.

There might be another job to be done to avoid diagnostic duplications
2023-02-15 08:13:41 +00:00
Dmitriy Novozhilov 88efa6bfb6 Update tests after switching to LV 1.9 2023-01-30 09:29:57 +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
Marco Pennekamp 5f554d0065 [FIR] KT-54980 Fix resolvability of too few/too many type arguments
- If too few or too many type arguments were provided, they were all
  thrown away in `TypeArgumentMapping`,
  `FirCallCompletionResultsWriterTransformer`, and `KtFirCallResolver`.
  The fix handles type arguments of the wrong arity more gracefully.
  - Note for `TypeArgumentMapping`: Excess type arguments are not needed
    for candidate resolution. Excess type arguments are still resolved
    due to the handling in `FirCallCompletionResultsWriterTransformer`.
- Post-processing in `AllCandidatesResolver`: When all candidates are
  resolved in `AllCandidatesResolver.getAllCandidates`, the function
  builds a FIR file. During that resolution, the
  `generic<String, String>` call (in example
  `functionCallWithTooFewTypeArguments.kt`) is correctly marked as
  inapplicable, but the missing type argument is inferred as an error
  type. `firFile` then contains a function call
  `generic<String, String, ERROR>` instead of `generic<String, String>`.
  This call is still marked as inapplicable. Despite that, the
  *subsequent* resolution by
  `bodyResolveComponents.callResolve.collectAllCandidates` disregards
  the call's inapplicability and resolves successfully into an
  applicable candidate. This is because `CandidateFactory` doesn't make
  any guarantees for already inapplicable calls. The fix adds
  post-processing to `AllCandidatesResolver` to preserve candidate
  inapplicability.
- Most tests that this commit changes had slightly different results due
  to type arguments becoming resolvable.
- `wrongNumberOfTypeArguments.kt` and
  `wrongNumberOfArgumentsInTypeAliasConstructor.kt`:
  `ConeDiagnostic.toFirDiagnostics` prefers specific errors. Because
  `ARGUMENT_TYPE_MISMATCH` is specific and `INAPPLICABLE_CANDIDATE` is
  not, only the former is reported. I see no reason to pass an illegally
  typed argument in either test, so the change reduces the errors to
  `INAPPLICABLE_CANDIDATE`.
- `typeAliasSamAdapterConstructors2.fir.kt`: See KT-55007.
- Disable `mismatchTypeParameters` JS backend test due to its handling
  of excess type arguments. See KT-55250.

^KT-54980 fixed
2023-01-02 16:36:02 +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 1b27d60307 [FIR] Support @OnlyInputTypes annotation
^KT-54807 Fixed
2022-11-22 15:46:17 +00:00
Dmitriy Novozhilov 22c21ca4df [FIR] Replace uninferred type variables and stub types during delegate inference 2022-11-03 08:30:07 +00:00
Mikhail Glukhikh e02fd8f4a8 FE: don't run builder inference in UNTIL_FIRST_LAMBDA mode
#KT-52927 Fixed
2022-09-09 12:44:39 +00:00
Simon Ogorodnik 05d486d55a Fix receiver inconsistency when builder inference restriction disabled
In 154e53c701 update of
extensionReceiverArgument in resolvedCall was accidentally moved into
language feature dependant block
2022-09-05 10:07:41 +00:00
Simon Ogorodnik 154e53c701 K1: add diagnostic BUILDER_INFERENCE_STUB_RECEIVER
It's reported on receivers in extension function calls with stub type,
as such calls can shadow members of finalized stub types causing
change of resolve when corresponding type argument specified explicitly

It works by checking extension receiver during call resolution parts run
That way we can easily detect if we found an extension applicable to
stub receiver and report call diagnostic for it

KT-53739
2022-08-30 10:19:26 +00:00
Simon Ogorodnik 105358dcf6 K1: add diagnostic BUILDER_INFERENCE_MULTI_LAMBDA_RESTRICTION
Let's call builder lambdas (BL) a lambda that has non-fixed input type
projection at the moment of lambda arguments analysis, such lambdas
is a subject to be analyzed with builder inference
Due to bug in constraint system joining algorithm, currently system
of two or more such lambdas may lead to unsound type inference

Diagnostic added here should be reported in case when there are two
BL that shares a common constraint system, while not annotated with
@BuilderInference, as a protection against aforementioned bug

It's reported by ConstraintSystemCompleter when such situation has
occurred during builder inference phase, it is the same place that
decides wherever lambdas is subject to builder inference or not

KT-53740
2022-08-30 10:19:25 +00:00
Mikhail Glukhikh f6ad6fb816 Add test for stub type receiver and for KT-53639 2022-08-30 10:19:24 +00:00
Mikhail Glukhikh 5cbecd276c FE: add test reproducing builder inference problem from KT-53422 2022-08-30 10:19:23 +00:00
Victor Petukhov 00d1e46c5a [FE 1.0] Don't throw exception during substitution of accessors, just return original 2022-07-22 16:03:53 +00:00
Victor Petukhov 3ed87c29c7 [FE 1.0] Substituted possible fixed type variables after completion in accordance with @OverloadResolutionByLambdaReturnType
^KT-48031 Fixed
2022-07-04 12:05:57 +00:00
Victor Petukhov 9e8ef56cca [FE 1.0] Imitate having builder inference annotation while trying resolve with a builder inference
^KT-52892 Fixed
2022-06-21 15:02:31 +02:00
Victor Petukhov fa7809cd80 [FE] Remove BuilderInference annotation from tests 2022-06-21 15:01:56 +02:00
Ivan Kochurkin fd2b4fd497 [FIR] Fix false positive USELESS_CAST on stub types, ^KT-50293 Fixed 2022-06-17 23:26:18 +00:00
Victor Petukhov b472ccd358 [FE 1.0] Introduce deprecation of inferred type variable into a declared upper bound within a builder inference call 2022-05-31 14:13:29 +00:00
Victor Petukhov 848075192c [FE 1.0] Don't use BuilderInferenceSubstitutionConstraintPosition for declared upper bound constraint with no substituted upper bound
It leads to further infer type variable into those upper bounds which is forbidden

Substituted upper bounds is ok because specific substituted types came from constraints of other proper positions, or if specific substituted type is from declared upper bound too, then there should be another declared upper bound with no substitution

^KT-51464 Fixed
^KT-47986 Fixed
2022-05-31 14:13:28 +00:00
Ivan Kochurkin feb3f41108 [FIR] Fix resolve inside lambda
The lambda is passed to extension function with type parameters
that defined inside this lambda

^KT-52197
^KT-52190 Fixed
2022-05-29 23:41:25 +03:00
Victor Petukhov efa267bf86 [FE] Fix tests after rebase 2022-05-27 13:56:34 +00:00
Victor Petukhov 06deaed3d5 Add test for KT-50498 2022-05-27 13:56:33 +00:00
Victor Petukhov c25e07119c [FE 1.0] Skip improper constraints while determining READY_FOR_FIXATION_DECLARED_UPPER_BOUND_WITH_SELF_TYPES type variable readiness
^KT-51148 Fixed
2022-05-27 13:56:32 +00:00
Victor Petukhov 7675361380 [FE 1.0] Continue completion of calls inside that builder inference call postponed type variables of which has already been inferred 2022-05-09 12:38:39 +00:00
Victor Petukhov 39d13442be [FE] Support intersection type emptiness checking for interfaces 2022-04-27 19:50:25 +00:00
Victor Petukhov 47d6236a2d [FIR] Support determining emptiness of an intersection type with type parameters' types 2022-04-27 19:50:23 +00:00
Simon Ogorodnik 9f6a812786 Fix multiple registration of same type variable in builder inference 2022-03-18 12:14:00 +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
Victor Petukhov 1a23cd8c45 [FE 1.0] Don't try to report specialized resolution ambiguity error for builder inference if the corresponding substitutor is empty
^KT-50989 Fixed
2022-01-27 15:30:16 +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
Dmitriy Novozhilov 5fc1e2e0cb [FIR] Don't create DNN types for flexible simple types
^KT-50788
2022-01-18 13:41:31 +03:00
Victor Petukhov a4a2f71fca Introduce deprecation cycle for reporting errors on some illegal equality calls inside a builder inference call
^KT-43493 Fixed
2022-01-17 19:44:16 +03:00
Victor Petukhov 060af85a93 Extract checks on equality expressions into a separate checker
^KT-43493 Fixed
2022-01-17 19:44:16 +03:00
Dmitriy Novozhilov 57346bac54 [FIR] Properly handle flexible types during creation of DNNT
^KT-50788 Fixed
2022-01-17 17:59:22 +03:00
Victor Petukhov 455b3143e7 [FE 1.0] Introduce builder inference stub types checker which may report more precise and clear errors due to resolution ambiguity
^KT-49828 Fixed
2022-01-11 18:34:47 +03:00
Victor Petukhov 8e2b90b5db [FE 1.0] Don't report CAST_NEVER_SUCCEEDS on stub types
^KT-49829 Fixed
2022-01-11 18:34:41 +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
Dmitriy Novozhilov f26059a7d3 [FE] Add clear warning about future changes about nullability of safe call with non nullable receiver
^KT-46860
2021-10-27 16:28:37 +03:00
Abduqodiri Qurbonzoda a3755a8e94 @UseExperimental -> @OptIn in compiler testData 2021-10-17 21:14:37 +00:00
Svyatoslav Kuzmich c88cde2f8b [Wasm] DONT_TARGET_WASM_BACKEND => IGNORE_BACKEND in testdata 2021-10-02 06:14:35 +00:00
Victor Petukhov ee728b6902 Use the new type inference for top-level callable reference resolution
^KT-47797 Fixed
^KT-47987 Fixed
^KT-45034 Fixed
^KT-48446 Fixed
^KT-13934 Fixed
2021-09-27 16:12:27 +03:00
Mikhail Glukhikh 3febabe977 Use OPT_IN instead of EXPERIMENTAL in diagnostic names 2021-09-10 16:29:13 +03:00
Dmitriy Novozhilov 0924216ed2 [FIR] Distinguish stub types for builder inference and for subtyping
^KT-48110 Fixed
2021-08-26 10:08:52 +03:00
Victor Petukhov bf1e68a53f Resolve calls using the builder inference despite the presence of the annotation if there are uninferred type variables
^KT-48194 Fixed
2021-08-20 01:28:11 +03:00
Victor Petukhov 55811c8851 Don't use builder inference if possible
The builder inference is running only if there are still uninferred type variables

^KT-48193 Fixed
2021-08-20 01:28:10 +03:00
Tianyu Geng 4726dcce40 FIR DFA: smartcast variable to Nothing? on null assignment
In order to make resolution still work for members not available from
`Nothing`, we track the type without `Nothing?` and use that for
resolution instead.
2021-08-06 22:57:15 +03:00
Tianyu Geng 0026560bd7 FIR: substitute the whole lambda body after builder inference 2021-08-06 22:57:13 +03:00
Victor Petukhov 13cb3c138a Update FE tests 2021-08-04 17:36:53 +03:00
Victor Petukhov cf3bd016be Always complete calls not related to the builder inference
^KT-47830 Fixed
2021-08-04 17:36:52 +03:00