Commit Graph

1042 Commits

Author SHA1 Message Date
Roman Efremov 6611a55a60 [FE] Relax rules of matching @Target annotation on expect and actual
Allow `expect` targets to be subset of `actual`.

^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov ad84c83ee9 [FE] Skip more special annotations in KMP annotation matching
Many errors are reported in stdlib with these annotations
(SinceKotlin, Deprecated, so on).
But having them only on expect is a valid case. E.g. SinceKotlin added
if some old platform-specific API becomes commonized.

^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov 234f453173 [FE, IR] Don't check SOURCE annotations if actual declaration has no source
^KT-58551
2023-07-24 09:48:49 +00:00
Roman Efremov 1a4ab9bb4b [FE] Implement FE logic of expect actual annotations matching
This implementation only checks annotations set on expect/actual
declarations and requires further refinement (e.g. checking of other
annotation targets, class scopes within typealiases).

^KT-58551
2023-07-24 09:48:48 +00:00
Dmitriy Novozhilov 1b24b95cde [FIR] Check for subtyping during actualization of supertypes of expect class
^KT-59356 Fixed
2023-06-22 07:05:31 +00:00
Dmitriy Novozhilov 623019cff1 [FE] Move substitutor related methods to TypeSystemContext
Also use TypeSystemContext instead of TypeSystemInferenceExtensionContext
  in AbstractExpectActualCompatibilityChecker

This is needed to have an ability to implement ExpectActualMatchingContext
  for IR backend. IrTypeSystemContext may operate with type substitutors,
  but there is no sense to implement all methods from TypeSystemInferenceExtensionContext
  in it
2023-06-10 07:33:29 +00:00
Dmitriy Novozhilov 8338370fbd [FE 1.0] Provide implementation of ExpectActualMatchingContext for FE 1.0
^KT-58578
2023-05-19 10:19:17 +00:00
Mikhail Glukhikh d4f81cf67f K1: remove unused resolution diagnostic
Related to KT-55079
2023-04-19 07:24:05 +00:00
Roman Efremov c718c77c43 [FE] Check visibilities of expected and actual property setters are compatible
^KT-30905 Fixed
2023-04-06 13:10:30 +00:00
Roman Efremov 456d3e0f42 [FE] Prohibit expect fun interface to have non-fun actual counterpart
In K1 .isFun is always false for Java classes, so extra check
is added for that. This is not needed for K2, because .isFun is
true for all Java classes. Here it is not necessary to check
that interface has only one method, because such check will be
done in the place where interface implementation is created.

^KT-39362 Fixed
2023-04-05 07:31:58 +00:00
Mikhail Glukhikh d76b32daf2 K1: rename 'kotlinCall' -> 'selectorCall' in relevant places 2023-04-03 16:35:55 +00:00
Mikhail Glukhikh bd27ec840c K1: report swallowed diagnostic about receiver type mismatch
#KT-55056 Fixed
2023-04-03 16:35:55 +00:00
Mikhail Glukhikh 930237b60e K1: report swallowed diagnostic about upper bound violation
#KT-55055 Fixed
2023-03-24 14:27:03 +00:00
Mikhail Glukhikh 7a58c2e99f DiagnosticReporterByTrackingStrategy: refactor positioning 2023-03-22 15:42:26 +00:00
Mikhail Glukhikh 97bec59bc9 K1: add forgotten INFERRED_INTO_DECLARED_UPPER_BOUNDS for incorporation case
#KT-56169 Fixed
2023-03-17 12:08:36 +00:00
Ilya Muradyan 6ddf32d013 Scripts: synchronize calculation of parent in LexicalScopeWrapper to fix #EA-803423 2023-03-01 09:05:25 +00:00
Dmitriy Novozhilov 89c42e20c9 [FIR] Consistently use _function_ instead of _functional_ in names of classes and functions 2023-02-02 08:24:52 +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
Dmitriy Novozhilov 32f6b71525 [FE] Add ability to configure PublicDeclaration type approximation configuration
This configuration allows to choose what to do with local and anonymous types
2022-11-22 15:46:18 +00:00
Mikhail Glukhikh d41c1e7e99 Code cleanup: ExpectedActualResolver 2022-11-17 22:28:04 +00:00
Mikhail Glukhikh 82f1535007 K1: fix IIOBE in expect-actual checker with different type parameter number
#KT-54827 Fixed
2022-11-17 22:28:04 +00:00
Ilya Muradyan 8d12342fc6 Add option for skipping calculating all names for optimizing reasons in LazyImportScope 2022-10-20 16:00:42 +02:00
Dmitriy Novozhilov d423782fac [FE 1.0] Remove usages of safeAs and cast from most of FE 1.0 modules:
- :core:descriptors
- :core:descriptors.jvm
- :core:deserialization
- :compiler:cli
- :compiler:frontend
- :compiler:frontend:cfg
- :compiler:frontend.java
- :compiler:frontend.common.jvm
- :compiler:psi
- :compiler:resolution
- :compiler:resolution.common
- :compiler:resolution.common.jvm
- :kotlin-reflect-api
2022-10-12 13:58:56 +00:00
Mikhail Glukhikh e9bb0f4fda Resolution: extract projections from captured flexible type properly
#KT-54100 Fixed
Related to KT-54196, KT-54198
2022-09-28 15:29:43 +00:00
Vladimir Dolzhenko b2b88662d8 Clean up
#KTIJ-23032
2022-09-27 15:17:27 +00:00
Dmitry Khalanskiy 4cbee3cde7 Fix KT-51478
The issue was that, when various context elements were available
to fulfill a need for an extension receiver, but none of them were
applicable to it, the compiler behaved the same way as if there
was no extension receiver at all.

https://youtrack.jetbrains.com/issue/KT-51478/Inapplicable-receiver-diagnostic-expected-when-there-are-two-context-receiver-candidates
2022-09-20 10:32:32 +00:00
Mikhail Glukhikh c4a48927d2 K1: report ABSTRACT_SUPER_CALL(_WARNING) also for 2+ steps to intersection
#KT-53953 Fixed
2022-09-16 07:15:43 +00:00
Mikhail Glukhikh 5fcb18ac2b Revert "[FE 1.0] Resolve this and super calls through the new type inference infra"
This reverts commit bab8047bb3.
2022-09-13 09:09:01 +00:00
Mikhail Glukhikh 393e99fa44 FE: don't run overload-by-lambda-return-type with unsuccessful candidates
Related to KT-52927
2022-09-09 16:12:24 +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
Mikhail Glukhikh 3bdd52b64a [FE 1.0] Return to the old type intersection emptiness check
This reverts commit 8227c4b603.
#KT-53656 Fixed
2022-09-06 17:57:01 +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
Denis.Zharkov 42c41a1916 Revert "[FE 1.0] Build captured type's supertypes in an alternative way: use own projection type as a first supertype, then supertypes from the corresponding type parameter's upper bounds"
This reverts commit eb19d39cbf.
2022-08-30 15:56:30 +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 b78106e437 Don't report INFERRED_..._INTO_EMPTY_INTERSECTION with explicit arguments 2022-08-19 14:01:38 +00:00
Victor Petukhov 8227c4b603 [FE 1.0] Use the new type intersection emptiness check
Also introduced compatibility mode to preserve compatibility for is/as/equality checks

^KT-29316 Related
2022-08-02 10:29:37 +00:00
Mikhail Glukhikh 3e58c54da9 Add docs to CandidateApplicability, remove DSL_SCOPE_VIOLATION 2022-07-27 15:29:48 +00:00
Mikhail Glukhikh d0c518013a Document&use CandidateApplicability.shouldStopResolve/isSuccess properly 2022-07-27 15:29:47 +00:00
Mikhail Glukhikh 0611f3b8e7 CandidateApplicability: add K1/K2 prefixes when applicable 2022-07-27 15:29:44 +00: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 bab8047bb3 [FE 1.0] Resolve this and super calls through the new type inference infra
^KT-48961 In progress
2022-07-22 16:03:48 +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 eb19d39cbf [FE 1.0] Build captured type's supertypes in an alternative way: use own projection type as a first supertype, then supertypes from the corresponding type parameter's upper bounds
The original case provoked forking a constraint system which isn't supported in K1 (K2 only). If the captured type is recursive, then type parameter's upper bounds may break subtyping due to substitution the current captured type again, into a recursive type parameter.

Note that we already have special logic for recursive captured types. See `isTypeVariableAgainstStarProjectionForSelfType`.

^KT-52782 Fixed
2022-06-18 14:04:40 +02:00
Mikhail Glukhikh d44f180aa9 FE 1.0: deprecate resolve to property when enum entry is at same level
See also KT-52802
#KT-49200 Fixed
2022-06-15 17:19:59 +00:00
Mikhail Zarechenskiy 372879b8e7 [FE 1.0] Don't fail with exception on unresolved type with type argument
^KT-50223 Fixed
2022-06-09 08:03:35 +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 867ad24c86 [FE] Show causing types in the INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION diagnostic 2022-05-27 15:14:24 +00:00
Victor Petukhov 6a34b184ac [FE] Introduce warnings on possible empty intersection types, and improve errors reporting in general
^KT-52361 Fixed
2022-05-27 15:14:23 +00:00