You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[constraint solution for a type variable]: https://github.com/dart-lang/language/blob/master/resources/type-system/inference.md#constraint-solution-for-a-type-variable
190
+
[constraint solution for a set of type variables]: https://github.com/dart-lang/language/blob/master/resources/type-system/inference.md#constraint-solution-for-a-set-of-type-variables
181
191
[grounded constraint solution for a type variable]: https://github.com/dart-lang/language/blob/master/resources/type-system/inference.md#grounded-constraint-solution-for-a-type-variable
192
+
[grounded constraint solution for a set of type variables]: https://github.com/dart-lang/language/blob/master/resources/type-system/inference.md#grounded-constraint-solution-for-a-set-of-type-variables
182
193
183
194
## Type inference algorithm for invocations
184
195
@@ -209,8 +220,10 @@ Performing type inference on an invocation consists of the following steps:
209
220
try to match the return type of the target function type as a subtype of the
210
221
invocation's type context. This produces an initial set of type constraints.
211
222
Then, using those constraints, find the constraint solution for the target
212
-
function type's type variables, considering bounds. This produces a
213
-
preliminary mapping of type variables to type schemas.
223
+
function type's type variables, using an initial partial solution that maps
224
+
all type variables to the unknown type. This produces a preliminary partial
225
+
solution for the inferred types, which will be updated in later type
226
+
inference steps.
214
227
215
228
4. Visit arguments: Partition the arguments into stages (see [argument
216
229
partitioning](#Argument-partitioning) below), and then for each stage _k_, do
@@ -246,15 +259,17 @@ Performing type inference on an invocation consists of the following steps:
246
259
247
260
* Horizontal inference: if generic inference is needed, and this is not the
248
261
last stage, use all the type constraints gathered so far to find the
249
-
constraint solution for the target function's type variables, considering
250
-
bounds. This produces an updated preliminary mapping of type parameters to
251
-
type schemas.
262
+
constraint solution for the target function's type variables, using the
263
+
preliminary partial solution from the most recent previous execution of
264
+
either this step or step 3. This produces an updated partial solution for
265
+
the inferred types.
252
266
253
267
5. Upwards inference: if generic inference is needed, use all the type
254
268
constraints gathered so far to find the **grounded** constraint solution for
255
-
the target function's type variables, considering bounds. This produces the
256
-
final mapping of type parameters to type schemas. Check that each type is a
257
-
subtype of the bound of its corresponding type parameter.
269
+
the target function's type variables, using the preliminary partial solution
270
+
from the most recent execution of step 4. This produces the final solution
271
+
for the inferred types. Check that each inferred type is a subtype of the
272
+
bound of its corresponding type parameter.
258
273
259
274
6. Type checking: Check that the static type of each argument is assignable to
260
275
the type obtained by substituting the final mapping (from step 5) into the
0 commit comments