Fix for exhaustiveness and sealed mixins.

Change-Id: I50916e5e3337638ac55edace6e4f181c8e045a4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-03-22 19:25:31 +00:00 committed by Commit Queue
parent 2eba00fabb
commit 812b607946
2 changed files with 2 additions and 22 deletions

View file

@ -113,7 +113,7 @@ class AnalyzerSealedClassOperations
@override
ClassElement? getSealedClass(DartType type) {
Element? element = type.element;
if (element is ClassElementImpl && element.isSealed) {
if (element is ClassElement && element.isSealed) {
return element;
}
return null;

View file

@ -156,15 +156,13 @@ void f(bool? x) {
]);
}
/// TODO(scheglov) Fix it.
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/51275')
test_alwaysExhaustive_boolNullable_true_false_null() async {
await assertNoErrorsInCode(r'''
void f(bool? x) {
switch (x) {
case true:
case false:
case Null:
case null:
break;
}
}
@ -343,24 +341,6 @@ void f(M x) {
]);
}
/// TODO(scheglov) Fix it.
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/51275')
test_alwaysExhaustive_sealedMixin_2at2() async {
await assertNoErrorsInCode(r'''
sealed mixin M {}
class A with M {}
class B with M {}
void f(M x) {
switch (x) {
case A():
case B():
break;
}
}
''');
}
test_alwaysExhaustive_typeVariable_bound_bool_true() async {
await assertErrorsInCode(r'''
void f<T extends bool>(T x) {