-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analyzer: Add a failing test for #38188
Also move tests for illegal_async_return_type Change-Id: Icd76c1ece456470ce734df2ac6628d5aedcd6e8e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129940 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
- Loading branch information
Showing
3 changed files
with
76 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
pkg/analyzer/test/src/diagnostics/illegal_async_return_type_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// 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 'package:analyzer/src/error/codes.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../dart/resolution/driver_resolution.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(IllegalAsyncReturnTypeTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class IllegalAsyncReturnTypeTest extends DriverResolutionTest { | ||
test_function_nonFuture() async { | ||
await assertErrorsInCode(''' | ||
int f() async {} | ||
''', [ | ||
error(StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, 0, 3), | ||
error(HintCode.MISSING_RETURN, 4, 1), | ||
]); | ||
} | ||
|
||
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/38188') | ||
test_function_nonFuture_withReturn() async { | ||
await assertErrorsInCode(''' | ||
int f() async { | ||
return 2; | ||
} | ||
''', [ | ||
error(StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, 0, 3), | ||
]); | ||
} | ||
|
||
test_function_subtypeOfFuture() async { | ||
await assertErrorsInCode(''' | ||
import 'dart:async'; | ||
abstract class SubFuture<T> implements Future<T> {} | ||
SubFuture<int> f() async { | ||
return 0; | ||
} | ||
''', [ | ||
error(StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, 73, 14), | ||
]); | ||
} | ||
|
||
test_method_nonFuture() async { | ||
await assertErrorsInCode(''' | ||
class C { | ||
int m() async {} | ||
} | ||
''', [ | ||
error(HintCode.MISSING_RETURN, 16, 1), | ||
error(StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, 12, 3), | ||
]); | ||
} | ||
|
||
test_method_subtypeOfFuture() async { | ||
await assertErrorsInCode(''' | ||
import 'dart:async'; | ||
abstract class SubFuture<T> implements Future<T> {} | ||
class C { | ||
SubFuture<int> m() async { | ||
return 0; | ||
} | ||
} | ||
''', [ | ||
error(StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, 85, 14), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters