Commit Graph

36 Commits

Author SHA1 Message Date
Victor Petukhov 7f7bb70596 Don't fix a type variable into the intersection type if there is an explicit expected type
^KT-43303 Fixed
^KT-42396 Fixed
^KT-42472 Fixed
2021-03-12 14:36:53 +03:00
Ilya Kirillov af4d300686 Use nullability from approximated local type in AbstractTypeApproximator 2021-02-19 16:44:47 +01:00
Dmitriy Novozhilov 3626008ed2 [Inference] Add ability to approximate local types in AbstractTypeApproximator 2021-02-19 12:47:27 +03:00
Simon Ogorodnik 3909e3c54c Decouple TypeCheckerContext and TypeSystemContext 2021-02-15 18:28:58 +03:00
Victor Petukhov dcad9c84fc Don't fix type variables into Nothing in priority way
^KT-44546 Fixed
2021-02-15 15:12:45 +03:00
Victor Petukhov 9efac8f68b Propagate all annotations during creating simple functional types
^KT-44563 Fixed
2021-01-29 13:50:46 +03:00
Victor Petukhov 977ac7cbe7 Propagate nullness flexibility into the result type from type variables in other constraints during result type finding, to prevent variable fixation to less flexible type
^KT-44540 Fixed
2021-01-27 17:23:15 +03:00
Victor Petukhov f06a5321a6 Approximate definitely not-null types for type parameter's types if they are already not-null (has not-null upper bounds)
^KT-44440 Fixed
2021-01-25 14:17:58 +03:00
Victor Petukhov 0dde5ddd7e Fail calls constraints of which contain uninferred type parameter
^KT-44055 Fixed

It's possible only if there is a callable reference among subcalls which go though the old type inference (and the error for uninferred type parameter wasn't reported)
2020-12-25 11:53:16 +03:00
Victor Petukhov 1926434b18 Report error about uninferred type parameter for some special call' subcalls 2020-12-25 11:53:14 +03:00
Jinseong Jeon 0ea6b32c01 NI: allow lower bound of flexible type for coercion-to-Unit
Example from
box/inference/coercionToUnitForLambdaReturnTypeWithFlexibleConstraint

// FILE: TestJ.java
public class TestJ {
  public static <T> In<T> materialize() { return null; }
}

// FILE: test.kt

class In<in T>

fun <T> inferred(e: In<T>?, l: () -> T): T = l()

fun box() {
  inferred(TestJ.materialize<Unit>(), { null })
}

`materialize` has flexible type, both for `In<T>` and `T`.
When analyzing `{ null }`, collected type constraints include:
ft<Unit?, Unit> <: T (from ft<In<ft<Unit, Unit?>>, In<ft<Unit, Unit?>>?>)

By allowing the lower bound of flexible type, FIR resolution can visit
`{ null }` with the expected type Unit, which will lead to proper
coercion to Unit at the end.
2020-12-15 17:52:48 +03:00
Victor Petukhov 04846ca47a Rework checking constraints by presented OnlyInputTypes annotation in accordance with changed incorporation mechanism 2020-11-25 11:15:23 +03:00
Victor Petukhov 0857b9c9e7 Rethink constraints incorporation
Namely, remove incorporation “otherInsideMyConstraint” to eliminate
constraint system redundancy and produce a potentially very large number
 of constructs.
Instead, introduce not so “spreadable” incorporation during variable
fixation (equality constraint with result type into other constraints).
^KT-41644 Fixed
^KT-42195 Fixed
^KT-42920 Fixed
^KT-42791 Fixed
^KT-41741 Fixed
2020-11-25 11:15:20 +03:00
Victor Petukhov 616e40f879 Reuse equality constraints during simplification in adding constraints 2020-11-25 11:15:19 +03:00
Alexander Udalov b3e79d36df Fix compiler warnings and some inspections 2020-11-03 14:00:53 +01:00
Victor Petukhov 84129098cb Add equality constraints without subtyping
^KT-42195 Fixed
^KT-41741 Fixed
2020-10-21 21:23:13 +03:00
Victor Petukhov c6da2a1138 Reuse built functional types for postponed arguments by expected types and paths from a top level type variable
^KT-42221 Fixed
2020-10-16 10:46:22 +03:00
Pavel Kirpichenkov 39a87435ee [FIR/NI] Refactor type variable gathering from lambda types
Motivation:
- drop getArguments from type context as a duplicate of getArgumentList
- reduce the number of collection allocations in getAllDeeplyRelatedTypeVariables

Additional minor improvements, test data fixes
2020-10-13 11:00:21 +03:00
Pavel Kirpichenkov 712a2ce1ab [FIR] Improved lambda completion: initial implementation
Repeat the logic of KotlinConstraintSystemCompleter in ConstraintSystemCompleter.
Implement additional context operations required for updated lambda completion algorithm.
2020-10-13 11:00:21 +03:00
Pavel Kirpichenkov 5eae6f2f4e [FIR] Move PostponedArgumentInputTypesResolver to resolution.common 2020-10-13 11:00:20 +03:00
Pavel Kirpichenkov 3822a32fce [FIR] Prepare commonization of PostponedArgumentInputTypesResolver 2020-10-13 11:00:20 +03:00
Victor Petukhov 6c1dc43d25 Add check already fixed variables in PostponedArgumentInputTypesResolver during adding constraints on them and using inside a functional type
^KT-42374 Fixed
2020-10-02 18:31:54 +03:00
Pavel Kirpichenkov 8f31b1ca83 [FIR] Use default language settings in inference components
Without settings common inference components require additional parameters
to be passed explicitly from components not shared between FIR and FE10.
Proper configuration can be postponed in FIR, defaults are good enough for now.

^KT-42080 In progress
2020-09-29 18:22:56 +03:00
Victor Petukhov 25ea3df5ca Put fix in 9123c4f73baf77f8a50dede6c890c46f5ffafd6c under the inference compatibility flag 2020-09-23 17:15:58 +03:00
Victor Petukhov bfb46befa5 Mark projection of a nullable captured type as not null during simplification constrains with it and a nullable type variable
^KT-41913 Fixed
2020-09-23 17:15:57 +03:00
Pavel Kirpichenkov fdc134ff66 [NI] Use compatibility mode for KT-41934 2020-09-22 15:06:12 +03:00
Pavel Kirpichenkov 896fbbd1a3 [NI] Add extra ordering for ready-for-fixation variables
Helps fixing to more specific type in the following situations:
Type1 <: Var1
Var2 <: Var1
Var2 <: Type2

Type1 and Type2 may also be nullable and non-nullable versions of the same type.
Note that no additional constraints can be inferred from such constraints before fixation.
Resulting types for variables will always Type1 and Type2 may also be nullable and non-nullable versions of the same type.
Fixing Var1 first will make Var2's type more specific while fixing Var2 first
will make Var1's type less specific. The first is preferrable in general.
2020-09-22 15:06:12 +03:00
Dmitriy Novozhilov bf91ada06c [NI] Suppress false positive IDEA warnings in NewConstraintSystemImpl 2020-09-11 12:13:34 +03:00
Dmitriy Novozhilov 7f692be11e [FIR] Properly detect callable reference type according conversions 2020-09-11 12:13:33 +03:00
Dmitriy Novozhilov a148db9d81 [FIR] Get rid of CandidateApplicability.SYNTHETIC_RESOLVED 2020-09-09 12:38:34 +03:00
Dmitriy Novozhilov 68f3d84e22 [FIR] Use CandidateApplicability from FE 1.0 2020-09-09 12:38:34 +03:00
Dmitriy Novozhilov cd557ad178 Change order of enum entries in CandidateApplicability 2020-09-09 12:38:34 +03:00
Dmitriy Novozhilov d1568c1ce6 Rename ResolutionCandidateApplicability to CandidateApplicability 2020-09-09 12:38:33 +03:00
Mikhail Zarechenskiy 9c217e3d99 Reuse revised variables during lambda analysis against type variables
#KT-41400 Fixed
2020-09-01 13:04:53 +03:00
Dmitriy Novozhilov 148e8fe76e Move FlatSignature to :compiler:resolution.common 2020-08-28 10:59:53 +03:00
Dmitriy Novozhilov 64766e125c Move common inference classes to :compiler:resolution.common 2020-08-28 10:59:53 +03:00