Files
sdk/pkg/front_end/testcases/nnbd_mixed/const_is.dart
T
Johnni Winther 4292d9cc28 [cfe] Handle required parameters in subtype check
+ use legacy erasure on weak mode const object checking
+ changes Null to subtype of Never when ignoring nullabilities

Closes #43606
Closes #43624

Change-Id: Ief695829c550562ec1bfd0c1145cc33c584a4b8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165805
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-10-06 08:34:23 +00:00

28 lines
1.1 KiB
Dart

// Copyright (c) 2020, 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.
// Test derived from language/nnbd/subtyping/function_type_bounds_weak_test
import 'const_is_lib.dart';
main() {
// void fn<T extends Object>() is void Function<T extends Object?>()
// Should pass with weak checking because when the nullability information on
// Object and Object? are erased the type bounds are equivalent.
expect(true, fnWithNonNullObjectBound is fnTypeWithNullableObjectBound);
const test1 = fnWithNonNullObjectBound is fnTypeWithNullableObjectBound;
expect(true, test1);
// void fn<T extends Null>() is void Function<T extends Never>()
// Should pass with weak checking because because Null becomes equivalent to
// the bottom type.
expect(true, fnWithNullBound is fnTypeWithNeverBound);
const test2 = fnWithNullBound is fnTypeWithNeverBound;
expect(true, test2);
}
expect(expected, actual) {
if (expected != actual) throw "Expected $expected, actual $actual";
}