Skip to content

Commit f6171a5

Browse files
authored
Update left top rule order in constraint solving (#1200)
Fix issue from #1035 . Update the algorithm for constraint solving to prefer decomposing the `dynamic` or `void` types on the left into `Object?` when matching against `Q?` for some `Q`.
1 parent 936b36e commit f6171a5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

resources/type-system/inference.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Status: Draft
66

77
## CHANGELOG
88

9+
2019.09.01
10+
- Fix incorrect placement of left top rule in constraint solving.
11+
912
2019.09.01
1013
- Add left top rule to constraint solving.
1114
- Specify inference constraint solving.
@@ -774,7 +777,9 @@ clauses need be tried.
774777
- If `P` is a legacy type `P0*` then the match holds under constraint set `C`:
775778
- Only if `P0` is a subtype match for `Q` under constraint set `C`.
776779
- If `Q` is a legacy type `Q0*` then the match holds under constraint set `C`:
777-
- Only if `P` is a subtype match for `Q?` under constraint set `C`.
780+
- If `P` is `dynamic` or `void` and `P` is a subtype match for `Q0` under
781+
constraint set `C`.
782+
- Or if `P` is a subtype match for `Q0?` under constraint set `C`.
778783
- If `Q` is `FutureOr<Q0>` the match holds under constraint set `C`:
779784
- If `P` is `FutureOr<P0>` and `P0` is a subtype match for `Q0` under
780785
constraint set `C`.
@@ -786,22 +791,21 @@ clauses need be tried.
786791
- If `Q` is `Q0?` the match holds under constraint set `C`:
787792
- If `P` is `P0?` and `P0` is a subtype match for `Q0` under
788793
constraint set `C`.
794+
- Or if `P` is `dynamic` or `void` and `Object` is a subtype match for `Q0`
795+
under constraint set `C`.
789796
- Or if `P` is a subtype match for `Q0` under **non-empty** constraint set
790-
`C`
791-
- Or if `P` is a subtype match for `Null` under constraint set `C`
797+
`C`.
798+
- Or if `P` is a subtype match for `Null` under constraint set `C`.
792799
- Or if `P` is a subtype match for `Q0` under **empty** constraint set
793-
`C`
800+
`C`.
794801
- If `P` is `FutureOr<P0>` the match holds under constraint set `C1 + C2`:
795802
- If `Future<P0>` is a subtype match for `Q` under constraint set `C1`
796803
- And if `P0` is a subtype match for `Q` under constraint set `C2`
797804
- If `P` is `P0?` the match holds under constraint set `C1 + C2`:
798805
- If `P0` is a subtype match for `Q` under constraint set `C1`
799806
- And if `Null` is a subtype match for `Q` under constraint set `C2`
800-
801807
- If `Q` is `dynamic`, `Object?`, or `void` then the match holds under no
802808
constraints.
803-
- If `P` is `dynamic` or `void` then the match holds under constraint set `C` if
804-
`Object?` is a subtype match for `Q` under constraint set `C`.
805809
- If `P` is `Never` then the match holds under no constraints.
806810
- If `Q` is `Object`, then the match holds under no constraints:
807811
- Only if `P` is non-nullable.

0 commit comments

Comments
 (0)