mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:11:19 +00:00
b101a7d002
Change-Id: Ib33169c3e0ffc870915c189404074a1dea472546 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196548 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Leaf Petersen <leafp@google.com>
86 lines
1.9 KiB
Dart
86 lines
1.9 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.
|
|
|
|
// @dart = 2.9
|
|
|
|
import "dart:async";
|
|
import "package:expect/expect.dart";
|
|
import "package:async_helper/async_helper.dart";
|
|
|
|
void main() async {
|
|
asyncStart();
|
|
|
|
// Sanity check.
|
|
Expect.equals(type<int>(), type(1));
|
|
|
|
{
|
|
int v = null; // // Variable with type T.
|
|
var f = await v; // // Variable with type FLATTEN(T).
|
|
Expect.equals(type<int>(), type(f)); // Dynamic check of static type of f.
|
|
int s = f; // // Static check upper bound of f.
|
|
f = 1; // // Static check lower bound of f.
|
|
s.toString(); // // Avoid "unused variable" warning.
|
|
}
|
|
|
|
{
|
|
Future<int> v = null;
|
|
var f = await v;
|
|
Expect.equals(type<int>(), type(f));
|
|
int s = f;
|
|
f = 1;
|
|
s.toString();
|
|
}
|
|
|
|
{
|
|
Future<Future<int>> v = null;
|
|
var f = await v;
|
|
Expect.equals(type<Future<int>>(), type(f));
|
|
Future<int> s = f;
|
|
f = Future<int>.value(1);
|
|
s.toString();
|
|
}
|
|
|
|
{
|
|
FutureOr<int> v = null;
|
|
var f = await v;
|
|
Expect.equals(type<int>(), type(f));
|
|
int s = f;
|
|
f = 1;
|
|
s.toString();
|
|
}
|
|
|
|
{
|
|
FutureOr<Future<int>> v = null;
|
|
var f = await v;
|
|
Expect.equals(type<Future<int>>(), type(f));
|
|
Future<int> s = f;
|
|
f = Future<int>.value(1);
|
|
s.toString();
|
|
}
|
|
|
|
{
|
|
Future<FutureOr<int>> v = null;
|
|
var f = await v;
|
|
Expect.equals(type<FutureOr<int>>(), type(f));
|
|
FutureOr<int> s = f;
|
|
f = 1;
|
|
f = Future<int>.value(1);
|
|
s.toString();
|
|
}
|
|
|
|
{
|
|
FutureOr<FutureOr<int>> v = null;
|
|
var f = await v;
|
|
Expect.equals(type<FutureOr<int>>(), type(f));
|
|
FutureOr<int> s = f;
|
|
f = 1;
|
|
f = Future<int>.value(1);
|
|
s.toString();
|
|
}
|
|
|
|
asyncEnd();
|
|
}
|
|
|
|
Type type<T>([T of]) => T;
|