Skip to content
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

Exhaustiveness uses extension type erasure #2420

Closed
eernstg opened this issue Dec 7, 2023 · 1 comment
Closed

Exhaustiveness uses extension type erasure #2420

eernstg opened this issue Dec 7, 2023 · 1 comment
Assignees
Labels
type-enhancement A request for a change that isn't a bug

Comments

@eernstg
Copy link
Member

eernstg commented Dec 7, 2023

@sgrekhov, do we have coverage for the following kind of situation?

sealed class S {}
class A extends S {}
class B extends S {}

extension type E(B it) {}

void f(S s) {
  var x = switch (s) {
    A() => 1,
    E() => 2,
  };
}

In a situation where we wish to determine whether or not a given switch (expression or statement) is exhaustive, we should use the extension type erasure of every extension type that we encounter (as an object pattern in a case, as the type of the matched value, in a cast pattern, whatever).

It is important that we consider the extension type erasure and not just the declared superinterface relationships of the extension types, because the actual exhaustiveness property is determined by the run-time types of the objects that we're working with, and that is again approximated at compile time by the extension type erasure (and not in a useful way by the extension type itself).

I don't remember seeing any tests of this nature, but I might have forgotten. It would be great if you could take a look, and put it on the TODO list if we don't have anything.

@sgrekhov
Copy link
Contributor

sgrekhov commented Dec 7, 2023

No, we don't. I'll add them, thank you!

@sgrekhov sgrekhov self-assigned this Dec 7, 2023
@sgrekhov sgrekhov added the type-enhancement A request for a change that isn't a bug label Dec 7, 2023
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Dec 12, 2023
eernstg pushed a commit that referenced this issue Dec 12, 2023
…#2423)

Add extension types exhaustiveness tests. Enums, trivial cases
eernstg pushed a commit that referenced this issue Dec 14, 2023
Add extension type exhaustiveness tests for lists
eernstg pushed a commit that referenced this issue Dec 14, 2023
Add extension type exhaustiveness tests about map patterns.
eernstg pushed a commit that referenced this issue Dec 18, 2023
Add extension type exhaustiveness tests about variable patterns.
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Dec 19, 2023
2023-12-19 sgrekhov22@gmail.com Fixes dart-lang/co19#2441. Fix roll failures (dart-lang/co19#2443)
2023-12-18 sgrekhov22@gmail.com Fixes dart-lang/co19#2435. Fix roll failures (dart-lang/co19#2437)
2023-12-18 sgrekhov22@gmail.com dart-lang/co19#2420. Add extension types exhaustiveness tests. Variables (dart-lang/co19#2431)
2023-12-15 sgrekhov22@gmail.com Fixes dart-lang/co19#2430. Update expected errors positions for CFE (dart-lang/co19#2433)
2023-12-15 sgrekhov22@gmail.com Fixes dart-lang/co19#2432. Remove excessive expected error for CFE (dart-lang/co19#2434)
2023-12-14 sgrekhov22@gmail.com dart-lang/co19#2420. Add extension types exhaustiveness tests. Maps (dart-lang/co19#2426)
2023-12-14 sgrekhov22@gmail.com dart-lang/co19#2420. Add extension types exhaustiveness tests. Lists (dart-lang/co19#2424)
2023-12-14 sgrekhov22@gmail.com dart-lang/co19#2139. Fix wrong failure of Language/Functions/element_type_A02_t06 (dart-lang/co19#2429)
2023-12-13 sgrekhov22@gmail.com dart-lang/co19#2350. Add more factory constructors tests (dart-lang/co19#2427)
2023-12-13 sgrekhov22@gmail.com Fixes dart-lang/co19#2415. Update `StreamController.broadcast()` test according to the changed documentation (dart-lang/co19#2425)
2023-12-13 sgrekhov22@gmail.com dart-lang/co19#2350. Add/update factory constructor tests. Part 4 (dart-lang/co19#2367)
2023-12-12 sgrekhov22@gmail.com dart-lang/co19#2420. Add extension types exhaustiveness tests. Enums, trivial cases (dart-lang/co19#2423)
2023-12-11 sgrekhov22@gmail.com dart-lang/co19#2420. Add extension types exhaustiveness tests. Enums (dart-lang/co19#2422)
2023-12-11 sgrekhov22@gmail.com dart-lang/co19#2386. Rename well-bounded tests. Update descriptions (dart-lang/co19#2405)
2023-12-08 sgrekhov22@gmail.com dart-lang/co19#2415. Change expectations for Stream.asyncMap() according to the current behavior (dart-lang/co19#2421)

Change-Id: I777eba4f1615c8477a5d2044f295696dfc210b1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342582
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Dec 22, 2023
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Dec 25, 2023
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Dec 26, 2023
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Dec 29, 2023
eernstg pushed a commit that referenced this issue Dec 29, 2023
#2452)

Add switch statement check to the existing exhaustiveness tests
eernstg pushed a commit that referenced this issue Jan 2, 2024
Add more dynamic semantics extension type tests.

Co-authored-by: Erik Ernst <eernst@google.com> (fixed a couple of typos).
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jan 3, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jan 4, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jan 5, 2024
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jan 5, 2024
2024-01-05 sgrekhov22@gmail.com Fixes dart-lang/co19#2465. Fix roll failures (dart-lang/co19#2466)
2024-01-04 sgrekhov22@gmail.com dart-lang/co19#2420. Add object-pattern exhaustiveness tests (dart-lang/co19#2454)
2024-01-04 sgrekhov22@gmail.com dart-lang/co19#2420. Add relational pattern exhaustiveness tests (dart-lang/co19#2463)
2024-01-03 sgrekhov22@gmail.com dart-lang/co19#2420. Add missed experimental flags (dart-lang/co19#2462)
2024-01-03 sgrekhov22@gmail.com Fixes dart-lang/co19#2436. Add test for external constructors with initializers (dart-lang/co19#2461)
2024-01-02 sgrekhov22@gmail.com dart-lang/co19#2420. Add more dynamic semantics extension type tests (dart-lang/co19#2459)
2024-01-02 sgrekhov22@gmail.com Fixes dart-lang/co19#2436. Add tests for external and redirecting constructors with initializing formals (dart-lang/co19#2460)
2023-12-29 sgrekhov22@gmail.com dart-lang/co19#1400. Add object pattern tests for extension types (dart-lang/co19#2456)
2023-12-29 sgrekhov22@gmail.com dart-lang/co19#1400. Add type inference tests for extension types (dart-lang/co19#2455)
2023-12-29 sgrekhov22@gmail.com dart-lang/co19#2420. Add switch statement check to the existing exhaustiveness tests (dart-lang/co19#2452)

Change-Id: Iee0668f14a35bb3c47aa67b35b1e5c6d8abe8021
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345040
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jan 8, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jan 8, 2024
eernstg pushed a commit that referenced this issue Jan 8, 2024
Add constant pattern exhaustiveness tests.
eernstg pushed a commit that referenced this issue Jan 9, 2024
Add another variable pattern exhaustiveness test
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jan 12, 2024
2024-01-12 sgrekhov22@gmail.com Fixes dart-lang/co19#2480. Fix typos, add issue numbers (dart-lang/co19#2481)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2477. Rename and reorder existing constants tests for match operators before adding new ones (dart-lang/co19#2478)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2420. Add null-check-pattern tests for extension types (dart-lang/co19#2475)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2119. Add missing experimental flags (dart-lang/co19#2474)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2119. Fix typo and improve error messages in Timer tests (dart-lang/co19#2473)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2471. Fix timer constructor tests. Add check for microtasks (dart-lang/co19#2472)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2428. Add `call` member tests for extension types (dart-lang/co19#2438)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2449. Update positions of analyzer expected errors (dart-lang/co19#2450)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2440. Add asyncStart/End() to Stream interface tests (dart-lang/co19#2457)
2024-01-09 sgrekhov22@gmail.com dart-lang/co19#2420. Add another variable pattern exhaustiveness test (dart-lang/co19#2469)
2024-01-08 sgrekhov22@gmail.com dart-lang/co19#2420. Add constant pattern exhaustiveness tests (dart-lang/co19#2467)
2024-01-08 sgrekhov22@gmail.com dart-lang/co19#2436. Add expected constant evaluation error for CFE (dart-lang/co19#2470)
2024-01-08 sgrekhov22@gmail.com dart-lang/co19#2420. Add null-assert pattern exhaustiveness tests (dart-lang/co19#2468)
2024-01-05 sgrekhov22@gmail.com dart-lang/co19#2420. Add parenthesized pattern exhaustiveness tests (dart-lang/co19#2464)

Change-Id: I86862732cca7c042120bf312403279c2cc10c135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345960
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jan 19, 2024
eernstg pushed a commit that referenced this issue Jan 22, 2024
Add more exhaustiveness tests
@sgrekhov sgrekhov reopened this Jan 24, 2024
eernstg pushed a commit that referenced this issue Jan 25, 2024
Exhaustiveness variable tests. Add switch statement check
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jan 26, 2024
2024-01-26 sgrekhov22@gmail.com dart-lang/co19#2485. Add constant evaluation tests for `Set` (dart-lang/co19#2509)
2024-01-26 sgrekhov22@gmail.com Fixes dart-lang/co19#2507. Fix roll failures (dart-lang/co19#2508)
2024-01-26 sgrekhov22@gmail.com dart-lang/co19#2485. Add is T constant evaluation tests (dart-lang/co19#2501)
2024-01-26 sgrekhov22@gmail.com dart-lang/co19#2485. Add `is! T` constant evaluation tests (dart-lang/co19#2504)
2024-01-25 sgrekhov22@gmail.com Fixes dart-lang/co19#2503. Update exhaustiveness_map_A02_t02.dart according to the flow analysis change (dart-lang/co19#2503)
2024-01-25 sgrekhov22@gmail.com dart-lang/co19#2420. Exhaustiveness variable tests. Add switch statement check (dart-lang/co19#2453)
2024-01-22 sgrekhov22@gmail.com dart-lang/co19#2485. Add more constant evaluation tests for record types (dart-lang/co19#2499)
2024-01-22 sgrekhov22@gmail.com dart-lang/co19#2420. Add more exhaustiveness tests (dart-lang/co19#2498)

Change-Id: If4af6cc1df4d44ad01e3578b8524748f67e7bac4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348660
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
eernstg pushed a commit that referenced this issue Jan 29, 2024
Add cast-pattern tests for extension types.
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Jan 30, 2024
eernstg pushed a commit that referenced this issue Feb 1, 2024
Add more exhaustiveness tests
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Feb 5, 2024
2024-02-02 sgrekhov22@gmail.com Fix dart-lang/co19#2517. Fix wrong test, add experimental flags (dart-lang/co19#2518)
2024-02-02 sgrekhov22@gmail.com Fix dart-lang/co19#2490. Update incompatible with await tests according to the changed rule (dart-lang/co19#2516)
2024-02-01 sgrekhov22@gmail.com dart-lang/co19#2420. Add more exhaustiveness tests (dart-lang/co19#2513)
2024-01-31 sgrekhov22@gmail.com dart-lang/co19#2446. Add additional test for cast pattern (dart-lang/co19#2514)
2024-01-30 sgrekhov22@gmail.com dart-lang/co19#1399. Add more tests for records (dart-lang/co19#2511)
2024-01-30 sgrekhov22@gmail.com dart-lang/co19#2485. Update map and list constant literals tests. Add parenthesized for records (dart-lang/co19#2512)
2024-01-29 sgrekhov22@gmail.com Fixes dart-lang/co19#2490. Add more await tests for extension types (dart-lang/co19#2500)
2024-01-29 sgrekhov22@gmail.com dart-lang/co19#2119. Fix typo in Subtyping tests description (dart-lang/co19#2510)
2024-01-29 sgrekhov22@gmail.com Fixes dart-lang/co19#2505. Add more tests for `call` member (dart-lang/co19#2506)
2024-01-29 sgrekhov22@gmail.com dart-lang/co19#2420. Add cast-pattern tests for extension types (dart-lang/co19#2458)

Change-Id: I631705a013f9a77910ae0f0be5a9fea01e7c719f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350240
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: William Hesse <whesse@google.com>
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
…heck (dart-lang#2453)

Exhaustiveness variable tests. Add switch statement check
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
…heck (dart-lang#2453)

Exhaustiveness variable tests. Add switch statement check
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
sgrekhov added a commit to sgrekhov/co19 that referenced this issue Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants