Skip to content

[Patterns] remove irrelevant specification of pattern type schemas. #2639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions accepted/future-releases/0546-patterns/feature-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -1570,22 +1570,16 @@ var (a, int b) = ... // Schema is `(?, int)`.

The context type schema for a pattern `p` is:

* **Logical-or**: The least upper bound of the context type schemas of the
branches.

* **Logical-and**: The greatest lower bound of the context type schemas of the
branches.

* **Null-check** or **null-assert**: A context type schema `E?` where `E` is
the context type schema of the inner pattern. *For example:*
* **Null-assert**: A context type schema `E?` where `E` is the context type
schema of the inner pattern. *For example:*

```dart
var [[int x]!] = [[]]; // Infers List<List<int>?> for the list literal.
```

* **Constant**: The context type schema is the static type of the pattern's
value.

* **Variable**:

1. In an assignment context, the context type schema is the static type of
Expand All @@ -1604,7 +1598,7 @@ The context type schema for a pattern `p` is:
// ^- Infers List<int>.
```

* **Relational** or **cast**: The context type schema is `?`.
* **Cast**: The context type schema is `?`.

* **Parenthesized**: The context type schema of the inner subpattern.

Expand Down Expand Up @@ -1675,6 +1669,10 @@ The context type schema for a pattern `p` is:
// ^-- Infer Foo<num>.
```

The pattern type schema for logical-or, null-check, constant, and relational
patterns is not defined, because those patterns are only allowed in refutable
contexts, and the pattern type schema is only used in irrefutable contexts.

#### Type checking and pattern required type

Once the value a pattern is matched against has a static type (which means
Expand Down