1572bb563f
Replaces all uses with the equivalent `TYPE_REF()` and `LEGACY_TYPE_REF()` because they are used in the shared dart:_rti library and there is no need to support both. Change-Id: I8c04eb12856cf6933a168f3e63351a45cd5d704e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344608 Reviewed-by: Mark Zhou <markzipan@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
54 lines
1.8 KiB
Dart
54 lines
1.8 KiB
Dart
// Copyright (c) 2019, 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.
|
|
|
|
import 'dart:_foreign_helper' show TYPE_REF;
|
|
import 'dart:_runtime' show gFnType, isSubtypeOf;
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
/// Returns an unwrapped generic function type with a bounded type argument in
|
|
/// the form: <T extends [bound]> void -> void.
|
|
///
|
|
// TODO(nshahan): The generic function type is created as a legacy type.
|
|
genericFunction(bound) =>
|
|
gFnType((T) => [TYPE_REF<void>(), []], (T) => [bound]);
|
|
|
|
/// Returns an unwrapped generic function type with a bounded type argument in
|
|
/// the form: <T extends [bound]> [argumentType] -> T.
|
|
///
|
|
// TODO(nshahan): The generic function type is created as a legacy type.
|
|
functionGenericReturn(bound, argumentType) => gFnType(
|
|
(T) => [
|
|
T,
|
|
[argumentType]
|
|
],
|
|
(T) => [bound]);
|
|
|
|
/// Returns an unwrapped generic function type with a bounded type argument in
|
|
/// the form: <T extends [bound]> T -> [returnType].
|
|
///
|
|
// TODO(nshahan): The generic function type is created as a legacy type.
|
|
functionGenericArg(bound, returnType) => gFnType(
|
|
(T) => [
|
|
returnType,
|
|
[T]
|
|
],
|
|
(T) => [bound]);
|
|
|
|
void checkSubtype(s, t) =>
|
|
Expect.isTrue(isSubtypeOf(s, t), '$s should be subtype of $t.');
|
|
|
|
void checkProperSubtype(s, t) {
|
|
Expect.isTrue(isSubtypeOf(s, t), '$s should be subtype of $t.');
|
|
checkSubtypeFailure(t, s);
|
|
}
|
|
|
|
void checkMutualSubtype(Object s, Object t) {
|
|
Expect.isTrue(isSubtypeOf(s, t), '$s should be subtype of $t.');
|
|
Expect.isTrue(isSubtypeOf(t, s), '$t should be subtype of $s.');
|
|
}
|
|
|
|
void checkSubtypeFailure(s, t) =>
|
|
Expect.isFalse(isSubtypeOf(s, t), '$s should not be subtype of $t.');
|