Fix #33415 no error for awaiting a void expression.
Bug: 33415 Change-Id: I4d4e81fef79a5bc5162e37ab07a8fe99e50c8dfc Reviewed-on: https://dart-review.googlesource.com/60522 Commit-Queue: Mike Fairhurst <mfairhurst@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
7b77fa217b
commit
9727a4a4ef
@@ -397,6 +397,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
||||
_errorReporter.reportErrorForToken(
|
||||
CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT, node.awaitKeyword);
|
||||
}
|
||||
_checkForUseOfVoidResult(node.expression);
|
||||
return super.visitAwaitExpression(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -653,4 +653,9 @@ class StaticWarningCodeTest_Kernel extends StaticWarningCodeTest_Driver {
|
||||
test_useOfVoidResult_variableDeclaration_method_ok() async {
|
||||
return super.test_useOfVoidResult_variableDeclaration_method_ok();
|
||||
}
|
||||
|
||||
@override
|
||||
test_useOfVoidResult_await() async {
|
||||
return super.test_useOfVoidResult_await();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5028,4 +5028,15 @@ class S {
|
||||
await computeAnalysisResult(source);
|
||||
assertNoErrors(source);
|
||||
}
|
||||
|
||||
test_useOfVoidResult_await() async {
|
||||
Source source = addSource(r'''
|
||||
main() async {
|
||||
void x;
|
||||
await x;
|
||||
}''');
|
||||
await computeAnalysisResult(source);
|
||||
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
|
||||
verify([source]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
library async_helper;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
bool _initialized = false;
|
||||
int _asyncLevel = 0;
|
||||
|
||||
@@ -81,7 +83,7 @@ void asyncSuccess(_) => asyncEnd();
|
||||
*
|
||||
* [f] must return a [:Future:] for the test computation.
|
||||
*/
|
||||
void asyncTest(f()) {
|
||||
Future<void> asyncTest(f()) {
|
||||
asyncStart();
|
||||
f().then(asyncSuccess);
|
||||
return f().then(asyncSuccess);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// 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:async' show Future;
|
||||
import 'dart:io' show Directory, File;
|
||||
|
||||
import 'package:expect/expect.dart' show Expect;
|
||||
@@ -22,7 +23,7 @@ main() async {
|
||||
}
|
||||
}
|
||||
|
||||
void testDart2jsCompile() async {
|
||||
Future<void> testDart2jsCompile() async {
|
||||
final Uri dart2jsUrl = Uri.base.resolve("pkg/compiler/bin/dart2js.dart");
|
||||
final Uri invalidateUri = Uri.parse("package:compiler/src/filenames.dart");
|
||||
Uri normalDill = outDir.uri.resolve("dart2js.full.dill");
|
||||
|
||||
@@ -2782,6 +2782,9 @@ LibTest/io/RandomAccessFile/writeString_A01_t02: CompileTimeError # Dart 1 const
|
||||
LibTest/io/RandomAccessFile/writeString_A01_t03: CompileTimeError # Dart 1 constants, https://github.com/dart-lang/sdk/issues/33894
|
||||
LibTest/io/Stdin/readLineSync_A03_t01: CompileTimeError # Dart 1 constants, https://github.com/dart-lang/sdk/issues/33894
|
||||
LibTest/io/Stdin/readLineSync_A03_t02: CompileTimeError # Dart 1 constants, https://github.com/dart-lang/sdk/issues/33894
|
||||
LibTest/io/Stdin/readLineSync_A03_t03: CompileTimeError # Erroneously awaits void
|
||||
LibTest/io/Stdin/readLineSync_A03_t04: CompileTimeError # Erroneously awaits void
|
||||
LibTest/io/Stdin/readLineSync_A04_t01: CompileTimeError # Erroneously awaits void
|
||||
LibTest/io/Stdout/add_A02_t01: CompileTimeError # Dart 1 constants, https://github.com/dart-lang/sdk/issues/33894
|
||||
LibTest/io/Stdout/encoding_A01_t01: CompileTimeError # Dart 1 constants, https://github.com/dart-lang/sdk/issues/33894
|
||||
LibTest/io/Stdout/writeAll_A01_t02: CompileTimeError # Dart 1 constants, https://github.com/dart-lang/sdk/issues/33894
|
||||
|
||||
@@ -146,7 +146,7 @@ Future _main(List<String> argv) async {
|
||||
throw "Unknown mode: $mode";
|
||||
}
|
||||
|
||||
await _writeSync(
|
||||
_writeSync(
|
||||
librariesJson.toFilePath(),
|
||||
jsonEncode({
|
||||
mode: {"libraries": locations}
|
||||
|
||||
Reference in New Issue
Block a user