@@ -385,7 +385,7 @@ into spaces:
385
385
* **Variable pattern:** An object space whose type is the variable's type
386
386
(which might be inferred).
387
387
388
- * **Literal or constant matcher :** These are handled specially depending on
388
+ * **Literal or constant pattern :** These are handled specially depending on
389
389
the constant's type:
390
390
391
391
* We treat `bool` like a sealed supertype with subtypes `true` and
@@ -426,10 +426,15 @@ into spaces:
426
426
the same string constant. Also the switch has a non-exhaustive error
427
427
since it doesn't match the entire `String` type.
428
428
429
- * **Null-check matcher:** An object space whose type is the underlying
430
- non-nullable type of the pattern. It contains a single field, `this` that
431
- returns the same value it is called on. That field's space is the lifted
432
- subpattern of the null-check pattern. For example:
429
+ * **Object pattern:** An object space whose type is the object pattern's type
430
+ and whose fields are the lifted fields of the object pattern. Positional
431
+ fields in the object pattern get implicit names like `field0`, `field1`,
432
+ etc.
433
+
434
+ * **Null-check pattern:** An object space whose type is the non-nullable
435
+ underlying type of the pattern's matched value type. It contains a single
436
+ field, `this` that returns the same value it is called on. That field's
437
+ space is the lifted subpattern of the null-check pattern. For example:
433
438
434
439
```dart
435
440
Card? card;
@@ -444,16 +449,15 @@ into spaces:
444
449
Card(this: Jack(oneEyed: true))
445
450
```
446
451
447
- * **Object pattern:** An object space whose type is the object pattern's type
448
- and whose fields are the lifted fields of the object pattern. Positional
449
- fields in the object pattern get implicit names like `field0`, `field1`,
450
- etc.
451
-
452
- * **Null-assert or cast binder:** An object space of type `top`.
452
+ * **Null-assert pattern:** The union of the lifted space of `null` and the
453
+ lifted space of the subpattern.
453
454
455
+ * **Cast pattern:** The space `(matched - cast) | subpattern` where `matched`
456
+ is the lifted space of the matched value type for this pattern, `cast` is
457
+ the lifted space for the type being cast to, and `subpattern` is the lifted
458
+ space for the subpattern.
454
459
455
- **TODO: Once generics are supported, describe how type patterns are lifted to
456
- spaces here.**
460
+ **TODO: Once generics are supported, describe how type arguments work.**
457
461
458
462
## The algorithm
459
463
0 commit comments