bd0e77c4fc
Bug: https://github.com/dart-lang/sdk/issues/52409 Change-Id: I675ed8f8cfa0d2e5327c2c6bc0fb1bda7bde038c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303840 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
29 lines
717 B
Dart
29 lines
717 B
Dart
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
/// Regression test for https://github.com/dart-lang/sdk/issues/52409.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
import "../static_type_helper.dart";
|
|
|
|
class A {
|
|
Never get getterThatReturnsNever => throw 0;
|
|
}
|
|
|
|
void f(Object? x) {
|
|
int? y = 0; // implicitly promotes to `int`
|
|
switch (x) {
|
|
case A(getterThatReturnsNever: _):
|
|
y = null;
|
|
default:
|
|
}
|
|
// `y = null` was unreachable, so `y` should still be promoted to `int`
|
|
y.expectStaticType<Exactly<int>>();
|
|
}
|
|
|
|
void main() {
|
|
f(0);
|
|
}
|