Commit Graph

795 Commits

Author SHA1 Message Date
Dmitriy Novozhilov b174bb8844 [FIR] Update testdata after introducing FirResolvedErrorReference 2022-12-15 12:12:19 +00:00
Ilya Kirillov 644d1bf0d0 [FIR] ignore tests which fail because of resolve contracts violation 2022-12-12 16:21:07 +00:00
Denis.Zharkov cd0d6d2773 Adjust test data for postponing ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated
^KT-55357 Related
^KT-36770 Related
2022-12-12 11:39:04 +00:00
Mikhail Glukhikh 758a4931e3 EmptyIntersectionTypeChecker: drop also incompatible supertypes check
Incompatible supertypes check also don't provoke runtime problems
in most situations, because this check is also bound to type argument
conflict. Related to KT-54411
2022-12-09 15:00:41 +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
Mikhail Glukhikh 832baf81e5 EmptyIntersectionTypeChecker: fix error in diagnostic text
Related to KT-54411
2022-12-09 15:00:39 +00:00
Mikhail Glukhikh d5c8d9fecc FE: add test reproducing KT-54411 2022-12-09 15:00:38 +00:00
Dmitriy Novozhilov ac7fddaad5 [FE] Always infer upper types to intersection types in K2...
...and always use old algorithm for K1

^KT-51221
2022-11-29 12:25:44 +00:00
Denis.Zharkov ca12cfb90d K2: Do not fix variables that has yet unprocessed constraints in forks
Otherwise, exception from org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector.TypeCheckerStateForConstraintInjector.fixedTypeVariable
might happen during forks resolution

The test data is extracted from intelliJ FP test

^KT-43296 Fixed
2022-11-24 17:29:30 +00:00
Denis.Zharkov b73acd7a3a K2: Apply constraints from forks at UNTIL_FIRST_LAMBDA completion phase
Otherwise, OVERLOAD_RESOLUTION_AMBIGUITY is reported for the calls to
the functions annotated as @OverloadResolutionByLambdaReturnType

^KT-43296 In Progress
2022-11-24 17:29:29 +00:00
Denis.Zharkov 10d63cc52a K2: Postpone inference forks resolution until FULL completion
It helps to use expected type information when choosing the branch
even in the nested calls

^KT-43296 In Progress
2022-11-24 17:29:29 +00:00
Denis.Zharkov 715a73c8fb K2: Support inference case with a mix of smart-cast and expected type
The idea is that we should not fix (i.e. choose any of the fork branches)
on the stage of candidate processing before completion, but it's enough
just to check that current state can be converged to success.

And when completion starts, and we add expected type to the system,
we've got more information to choose the correct fork branch.

NB: The old `processForkConstraints` is being called just
at the beginning of the completion phase.

^KT-43296 In Progress
2022-11-24 17:29:28 +00:00
Dmitriy Novozhilov 0e84bf2053 [FIR] Don't report ARGUMENT_TYPE_MISMATCH on error types 2022-11-22 15:46:19 +00:00
Dmitriy Novozhilov 1b27d60307 [FIR] Support @OnlyInputTypes annotation
^KT-54807 Fixed
2022-11-22 15:46:17 +00:00
Anna Kozlova c727dbb8ca [fir compiler] ensure type parameters are included in the resolve scope
to resolve the next parameter bounds (KTIJ-23674)
2022-11-16 22:25:02 +00:00
Dmitriy Novozhilov e6ce008415 [FIR] Ignore leaked internal types because of KT-54568 2022-11-03 08:30:09 +00:00
Dmitriy Novozhilov 22c21ca4df [FIR] Replace uninferred type variables and stub types during delegate inference 2022-11-03 08:30:07 +00:00
pyos 7787638737 FIR: fix substitution of anonymous type's supertype again
^KT-51418 Fixed
2022-11-01 15:28:41 +00:00
Ivan Kochurkin 1deb253bac [FIR] Run FirSupertypesChecker for anonymous objects, ^KT-54300 Fixed 2022-10-13 18:11:49 +00:00
Ivan Kochurkin 9c6df5313a [FIR] Fix substitution of anonymous type's supertypes, ^KT-51418 Fixed 2022-10-13 18:11:47 +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 a4b2a8c4ea AbstractTypeChecker: fix special case with CapturedType as self type argument
#KT-53908 Fixed
May fix also KT-53271
2022-09-19 19:12:21 +00:00
pyos be5c4a91a4 FIR/FE1.0: keep flexibility when approximating local types 2022-09-14 08:11:04 +00:00
pyos adcbc5ec99 FE1.0: keep nullability when approximating local types (in 1.9)
Report an error that inference will change and type has to be provided
manually in other language versions, since the current behavior is an
unsoundness that can cause runtime NPEs while the new behavior may
silently change overload resolution.

^KT-30054 Fixed
2022-09-14 08:11:04 +00:00
pyos 062308c7c1 FIR: keep nullability when approximating local types
^KT-30054 Open
2022-09-14 08:11:04 +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
Denis.Zharkov 490382b77f Add test for KT-52782
It just demonstrates/fixate the current "broken" behavior in K1
that we unfortunately have and that is fixed in K2
2022-08-31 09:45:54 +00:00
Denis.Zharkov db1bd4f232 Add test for KT-53124
The issue itself is supposed to be fixed after eb19d39cbf reverted

^KT-53124 Fixed
2022-08-30 15:56:31 +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 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
Mikhail Glukhikh b78106e437 Don't report INFERRED_..._INTO_EMPTY_INTERSECTION with explicit arguments 2022-08-19 14:01:38 +00:00
Mikhail Glukhikh a6b90fcb8e Add a test with false positive "inferred into empty intersection"
Related to KT-50232
2022-08-19 14:01:37 +00:00
Simon Ogorodnik 2a16fe1d0f FIR: Fix overloading by type-arguments
In K1, upper bound violated causes candidate to have lower applicability
due to constraint errors, in K2 however constraint errors has to be
reported explicitly
2022-08-04 22:56:08 +02: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 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
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 5b5da025f4 [FE 1.0] Don't throw empty intersection exception, return empty intersection type instead 2022-07-04 12:05:56 +00:00
Ilya Chernikov bb996c1b27 Switch kotlin version to 1.8
with appropriate fixes in testdata, tests and other
places.
2022-06-29 10:20:30 +02: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
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
Ivan Kochurkin fd2b4fd497 [FIR] Fix false positive USELESS_CAST on stub types, ^KT-50293 Fixed 2022-06-17 23:26:18 +00:00
Ivan Kochurkin 9f69ea1786 [FIR] Add TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM diagnostics, ^KT-52327 Fixed 2022-06-17 23:26:16 +00:00
Jinseong Jeon a2da690afd Test: add java source files as JavaSourceRoot
so that those can be properly populated in SingleJavaRootsIndex
2022-06-16 22:14:17 +02:00
Nikolay Lunyak be9e97d044 [FIR] Introduce ConeDynamicType 2022-06-02 13:47:23 +00:00