Skip to content

Commit aab3033

Browse files
authored
Move up the intersection type rules in the definition of UP (#3435)
Move the intersection type rules up in the definition of `UP`, such that no results are of the form `(X & B)?`. The point is that types of the form `(X & B)?` are not intended to occur at all, and this change will ensure that `UP` will not create any such type. For further information, see: - Implementation: https://dart-review.googlesource.com/c/sdk/+/333922 - Breaking change request: dart-lang/sdk#53883
1 parent f65daa6 commit aab3033

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

resources/type-system/upper-lower-bounds.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ [email protected]
44

55
## CHANGELOG
66

7+
2023.10.27
8+
- **CHANGE** Update **UP** to handle intersection types earlier. This
9+
prevents **UP** from producing results of the form `(X & B)?`.
10+
711
2020.09.01
812
- **CHANGE** Update **UP** in cases about type variables and promoted type
913
variables involving F-bounds, and in two cases about function types.
@@ -81,6 +85,20 @@ We define the upper bound of two types T1 and T2 to be **UP**(`T1`,`T2`) as foll
8185
- **UP**(`T1`, `T2`) = `T2` if **BOTTOM**(`T1`)
8286
- **UP**(`T1`, `T2`) = `T1` if **BOTTOM**(`T2`)
8387

88+
- **UP**(`X1 & B1`, `T2`) =
89+
- `T2` if `X1 <: T2`
90+
- otherwise `X1` if `T2 <: X1`
91+
- otherwise **UP**(`B1a`, `T2`)
92+
where `B1a` is the greatest closure of `B1` with respect to `X1`,
93+
as defined in [inference.md].
94+
95+
- **UP**(`T1`, `X2 & B2`) =
96+
- `X2` if `T1 <: X2`
97+
- otherwise `T1` if `X2 <: T1`
98+
- otherwise **UP**(`T1`, `B2a`)
99+
where `B2a` is the greatest closure of `B2` with respect to `X2`,
100+
as defined in [inference.md].
101+
84102
- **UP**(`T1`, `T2`) where **NULL**(`T1`) and **NULL**(`T2`) =
85103
- `T2` if **MOREBOTTOM**(`T1`, `T2`)
86104
- `T1` otherwise
@@ -126,27 +144,13 @@ We define the upper bound of two types T1 and T2 to be **UP**(`T1`,`T2`) as foll
126144
where `B1a` is the greatest closure of `B1` with respect to `X1`,
127145
as defined in [inference.md].
128146

129-
- **UP**(`X1 & B1`, `T2`) =
130-
- `T2` if `X1 <: T2`
131-
- otherwise `X1` if `T2 <: X1`
132-
- otherwise **UP**(`B1a`, `T2`)
133-
where `B1a` is the greatest closure of `B1` with respect to `X1`,
134-
as defined in [inference.md].
135-
136147
- **UP**(`T1`, `X2 extends B2`) =
137148
- `X2` if `T1 <: X2`
138149
- otherwise `T1` if `X2 <: T1`
139150
- otherwise **UP**(`T1`, `B2a`)
140151
where `B2a` is the greatest closure of `B2` with respect to `X2`,
141152
as defined in [inference.md].
142153

143-
- **UP**(`T1`, `X2 & B2`) =
144-
- `X2` if `T1 <: X2`
145-
- otherwise `T1` if `X2 <: T1`
146-
- otherwise **UP**(`T1`, `B2a`)
147-
where `B2a` is the greatest closure of `B2` with respect to `X2`,
148-
as defined in [inference.md].
149-
150154
- **UP**(`T Function<...>(...)`, `Function`) = `Function`
151155
- **UP**(`Function`, `T Function<...>(...)`) = `Function`
152156

0 commit comments

Comments
 (0)