mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
Issue 38799. Test that function expressions can infer Never as return type.
R=brianwilkerson@google.com Bug: https://github.com/dart-lang/sdk/issues/38799 Change-Id: I1093749cb31a00a1b450c23ec4631595bce4bd00 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149605 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
058e25875c
commit
197bc061b9
1 changed files with 28 additions and 0 deletions
|
@ -232,6 +232,27 @@ var v = () {
|
|||
_assertReturnType('() {', 'int');
|
||||
}
|
||||
|
||||
test_noContext_returnType_sync_blockBody_dynamic() async {
|
||||
await resolveTestCode('''
|
||||
var v = (dynamic a) {
|
||||
return a;
|
||||
};
|
||||
''');
|
||||
_assertReturnType('(dynamic a) {', 'dynamic');
|
||||
}
|
||||
|
||||
test_noContext_returnType_sync_blockBody_Never() async {
|
||||
await resolveTestCode('''
|
||||
var v = () {
|
||||
throw 42;
|
||||
};
|
||||
''');
|
||||
_assertReturnType(
|
||||
'() {',
|
||||
typeStringByNullability(nullable: 'Never', legacy: 'Null'),
|
||||
);
|
||||
}
|
||||
|
||||
test_noContext_returnType_sync_blockBody_notNullable() async {
|
||||
await resolveTestCode('''
|
||||
var v = (bool b) {
|
||||
|
@ -327,6 +348,13 @@ main() {
|
|||
);
|
||||
}
|
||||
|
||||
test_noContext_returnType_sync_expressionBody_dynamic() async {
|
||||
await resolveTestCode('''
|
||||
var v = (dynamic a) => a;
|
||||
''');
|
||||
_assertReturnType('(dynamic a) =>', 'dynamic');
|
||||
}
|
||||
|
||||
test_noContext_returnType_sync_expressionBody_Never() async {
|
||||
await resolveTestCode('''
|
||||
var v = () => throw 42;
|
||||
|
|
Loading…
Reference in a new issue