Skip to content

Commit 6f0beaf

Browse files
Apply the suggestions from the review comments
1 parent f9e4d4c commit 6f0beaf

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

accepted/future-releases/3009-inference-using-bounds/design-document.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fun main() {
178178
```
179179

180180
Let's take a look at the source of the described type inference
181-
behaviour in Dart.
181+
behavior in Dart.
182182

183183
## Constraint solution for a set of type variables
184184

@@ -194,7 +194,7 @@ is limited in two ways:
194194

195195
A convenient way to graphically represent CSSTV is by a rectangle,
196196
where three sides of it take the three inputs relevant to this
197-
proposal, and the fourth side produces the output. The relevant inputs
197+
feature, and the fourth side produces the output. The relevant inputs
198198
are (1) the preliminary solution found by the previous phase of the
199199
inference, (2) the constraints collected during the current phase of
200200
the inference, and (3) the bounds of the type variables. The output of
@@ -583,17 +583,20 @@ block-beta
583583
csstvUpwards -- "{X = B}" --> overallOutput
584584
```
585585

586-
## More examples enabled by the current proposal
586+
## More examples enabled by this feature
587587

588-
In addition to the motivating examples, both the original and the more
589-
complex, being handled by the current proposal, some cases of non
590-
F-bounded type variables are enabled by it as well.
588+
In addition to both motivating examples, this feature also handles
589+
some cases involving type variables that are not F-bounded.
591590

592-
The following example demonstrates a tempting assumption that doesn't
593-
hold today, but will hold with the proposed update. The developers
594-
might think that they will get the extracted type value for `Y` when
595-
they specify a type value for `X`. We remember similar cases occurring
596-
in practice.
591+
With a class like `A` below, and with this feature, the constructor
592+
invocation in `test` is inferred as `A<List<num>, num>(<num>[])`.
593+
Without this feature, it is inferred as `A<List<num>, dynamic>(<num>[])`.
594+
595+
Intuitively, this happens because the type inference algorithm without this
596+
feature is unable to detect that there is a relationship between `X` and `Y`.
597+
With this feature one could say that the value of `Y` is "extracted" from
598+
the value of `X`. We have seen cases in practice demonstrating that the
599+
ability to transfer this information during type inference is useful.
597600

598601
```dart
599602
class A<X extends Iterable<Y>, Y> {
@@ -608,9 +611,7 @@ test() {
608611
```
609612

610613
[#3009]: https://github.com/dart-lang/language/issues/3009
611-
612614
[CSSTV]: https://github.com/dart-lang/language/blob/main/resources/type-system/inference.md#constraint-solution-for-a-set-of-type-variables
613-
614615
[subtype-constraint-generation]: https://github.com/dart-lang/language/blob/main/resources/type-system/inference.md#subtype-constraint-generation
615616

616617
## Changelog

0 commit comments

Comments
 (0)