mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:09:04 +00:00
84e3c8b50f
Closes https://github.com/dart-lang/sdk/pull/50920 GitOrigin-RevId: fa87531bd0f52b69485c9d02ff9e44a4a29c6a91 Change-Id: I0ae8574a5b77087895e004079f221201bb550cf3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278535 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: Alexander Thomas <athom@google.com>
215 lines
2.6 KiB
Dart
215 lines
2.6 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.
|
|
|
|
// VMOptions=
|
|
// VMOptions=--dwarf_stack_traces --no-retain_function_objects --no-retain_code_objects
|
|
|
|
import 'dart:async' as async;
|
|
import 'lib.dart' as l; // Minimal library containing "int async;".
|
|
|
|
// Adapted from Analyzer test testing where `async` was not previously allowed.
|
|
|
|
// Helpers
|
|
void ignore(argument) {}
|
|
|
|
class GNamed {
|
|
void g({Object? async = null}) {}
|
|
}
|
|
|
|
class AGet {
|
|
int get async => 1;
|
|
set async(int i) {}
|
|
}
|
|
|
|
class ACall {
|
|
int async() => 1;
|
|
}
|
|
|
|
main() {
|
|
// Each test declares a separate async function, tests that `async`
|
|
// can occur in it, and makes sure the function is run.
|
|
{
|
|
const int async = 0;
|
|
f() async {
|
|
g(@async x) {}
|
|
g(0);
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f(c) async {
|
|
c.g(async: 0);
|
|
}
|
|
|
|
f(GNamed());
|
|
}
|
|
{
|
|
f() async {
|
|
var async = 1;
|
|
ignore(async);
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async* {
|
|
var async = 1;
|
|
ignore(async);
|
|
}
|
|
|
|
f().forEach(ignore);
|
|
}
|
|
{
|
|
f() async {
|
|
async:
|
|
while (true) {
|
|
break async;
|
|
}
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
g() {}
|
|
f() async {
|
|
try {
|
|
g();
|
|
} catch (async) {}
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
g() {}
|
|
f() async {
|
|
try {
|
|
g();
|
|
} catch (e, async) {}
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
async:
|
|
while (true) {
|
|
if (false) continue async;
|
|
break;
|
|
}
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
var async;
|
|
f() async {
|
|
for (async in []) {}
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
g(int async) {}
|
|
g(0);
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
return new AGet().async;
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
return new ACall().async();
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
return new ACall()..async();
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
g() {}
|
|
f() async {
|
|
async:
|
|
g();
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
int async() => 0;
|
|
async();
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
return async.Future.value(0);
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
new AGet().async = 1;
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
return new AGet()..async = 1;
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
int async = 1;
|
|
f() async {
|
|
return "$async";
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
return l.async;
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() async {
|
|
switch (0) {
|
|
async:
|
|
case 0:
|
|
break;
|
|
}
|
|
}
|
|
|
|
f();
|
|
}
|
|
{
|
|
f() sync* {
|
|
var async = 1;
|
|
ignore(async);
|
|
}
|
|
|
|
f();
|
|
}
|
|
}
|