[cfe] Update test expectation for language/unsorted/flatten_test/12

+ use the inferred return type in error reporting when no return type is
declared. This turned up in this particular case where we report an
error between the returned value and the inferred return type.

Closes #42546

Change-Id: I48da24047f2e92ca91a514dfcb43c2ba6f65ee46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153610
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2020-07-10 07:01:18 +00:00 committed by commit-bot@chromium.org
parent cf7a63afe6
commit 27446b463e
19 changed files with 213 additions and 13 deletions

View file

@ -484,8 +484,8 @@ class _AsyncClosureContext implements ClosureContext {
// flatten(S) is neither void, dynamic, Null.
statement.expression = inferrer.helper.wrapInProblem(
new NullLiteral()..fileOffset = statement.fileOffset,
templateInvalidReturnAsync.withArguments(expressionType,
_declaredReturnType, inferrer.isNonNullableByDefault),
templateInvalidReturnAsync.withArguments(
expressionType, returnType, inferrer.isNonNullableByDefault),
statement.expression.fileOffset,
noLength)
..parent = statement;
@ -496,8 +496,8 @@ class _AsyncClosureContext implements ClosureContext {
// nor dynamic, and flatten(S) is void.
statement.expression = inferrer.helper.wrapInProblem(
new NullLiteral()..fileOffset = statement.fileOffset,
templateInvalidReturnAsync.withArguments(expressionType,
_declaredReturnType, inferrer.isNonNullableByDefault),
templateInvalidReturnAsync.withArguments(
expressionType, returnType, inferrer.isNonNullableByDefault),
statement.expression.fileOffset,
noLength)
..parent = statement;
@ -513,7 +513,7 @@ class _AsyncClosureContext implements ClosureContext {
futureValueType, expressionType, statement.expression,
fileOffset: statement.expression.fileOffset,
runtimeCheckedType: _returnContext,
declaredContextType: _declaredReturnType,
declaredContextType: returnType,
isVoidAllowed: false,
errorTemplate: templateInvalidReturnAsync)
..parent = statement;

View file

@ -160,6 +160,7 @@ discovering
dispatcher
dispose
dist
divergent
doctype
doesnt
dog

View file

@ -0,0 +1,17 @@
// 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.
// Based on tests/language/unsorted/flatten_test/12
import 'dart:async';
class Divergent<T> implements Future<Divergent<Divergent<T>>> {
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
test() async {
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
}
main() {}

View file

@ -0,0 +1,31 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:async" as asy;
import "dart:async";
class Divergent<T extends core::Object? = dynamic> extends core::Object implements asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>> {
synthetic constructor •() → self::Divergent<self::Divergent::T%>
;
method noSuchMethod(core::Invocation invocation) → dynamic
;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ catchError(core::Function onError, {(core::Object) →? core::bool test = #C1}) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#catchError, 0, const <core::Type*>[], core::List::unmodifiable<dynamic>(<dynamic>[onError]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#test: test}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ whenComplete(() → FutureOr<void>action) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#whenComplete, 0, const <core::Type*>[], core::List::unmodifiable<dynamic>(<dynamic>[action]), core::Map::unmodifiable<core::Symbol*, dynamic>(const <core::Symbol*, dynamic>{}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ timeout(core::Duration timeLimit, {generic-covariant-impl () →? FutureOr<self::Divergent<self::Divergent<self::Divergent::T%>>>onTimeout = #C1}) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#timeout, 0, const <core::Type*>[], core::List::unmodifiable<dynamic>(<dynamic>[timeLimit]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#onTimeout: onTimeout}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ then<R extends core::Object? = dynamic>((self::Divergent<self::Divergent<self::Divergent::T%>>) → FutureOr<self::Divergent::then::R%>onValue, {core::Function? onError = #C1}) → asy::Future<self::Divergent::then::R%>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#then, 0, core::List::unmodifiable<core::Type*>(<core::Type*>[self::Divergent::then::R%]), core::List::unmodifiable<dynamic>(<dynamic>[onValue]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#onError: onError}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent::then::R%>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ asStream() → asy::Stream<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#asStream, 0, const <core::Type*>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol*, dynamic>(const <core::Symbol*, dynamic>{}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Stream<self::Divergent<self::Divergent<self::Divergent::T%>>>;
}
static method test() → dynamic async
;
static method main() → dynamic
;
constants {
#C1 = null
}

View file

@ -0,0 +1,66 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/issue42546.dart:14:58: Error: A value of type 'Divergent<int>' can't be returned from an async function with return type 'Future<Divergent<Divergent<Divergent<int>>>>'.
// - 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
// - 'Future' is from 'dart:async'.
// Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
// ^
//
// pkg/front_end/testcases/nnbd/issue42546.dart:14:75: Error: A value of type 'Future<Divergent<Divergent<Divergent<int>>>>' can't be assigned to a variable of type 'Future<Divergent<Divergent<int>>>'.
// - 'Future' is from 'dart:async'.
// - 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
// Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
// ^
//
import self as self;
import "dart:core" as core;
import "dart:async" as asy;
import "dart:async";
class Divergent<T extends core::Object? = dynamic> extends core::Object implements asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>> {
synthetic constructor •() → self::Divergent<self::Divergent::T%>
: super core::Object::•()
;
method noSuchMethod(core::Invocation invocation) → dynamic
return super.{core::Object::noSuchMethod}(invocation);
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ catchError(core::Function onError, {(core::Object) →? core::bool test = #C1}) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C2, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[onError]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C4: test}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ whenComplete(() → FutureOr<void>action) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C5, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[action]), core::Map::unmodifiable<core::Symbol*, dynamic>(#C7))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ timeout(core::Duration timeLimit, {generic-covariant-impl () →? FutureOr<self::Divergent<self::Divergent<self::Divergent::T%>>>onTimeout = #C1}) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C8, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[timeLimit]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C9: onTimeout}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ then<R extends core::Object? = dynamic>((self::Divergent<self::Divergent<self::Divergent::T%>>) → FutureOr<self::Divergent::then::R%>onValue, {core::Function? onError = #C1}) → asy::Future<self::Divergent::then::R%>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C10, 0, core::List::unmodifiable<core::Type*>(<core::Type*>[self::Divergent::then::R%]), core::List::unmodifiable<dynamic>(<dynamic>[onValue]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C11: onError}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent::then::R%>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ asStream() → asy::Stream<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C12, 0, #C3, #C6, core::Map::unmodifiable<core::Symbol*, dynamic>(#C7))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Stream<self::Divergent<self::Divergent<self::Divergent::T%>>>;
}
static method test() → dynamic async {
asy::Future<self::Divergent<self::Divergent<core::int>>> x = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42546.dart:14:75: Error: A value of type 'Future<Divergent<Divergent<Divergent<int>>>>' can't be assigned to a variable of type 'Future<Divergent<Divergent<int>>>'.
- 'Future' is from 'dart:async'.
- 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
^" in (() → asy::Future<self::Divergent<self::Divergent<self::Divergent<core::int>>>> async => let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue42546.dart:14:58: Error: A value of type 'Divergent<int>' can't be returned from an async function with return type 'Future<Divergent<Divergent<Divergent<int>>>>'.
- 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
- 'Future' is from 'dart:async'.
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
^" in new self::Divergent::•<core::int>() as{TypeError,ForNonNullableByDefault} self::Divergent<self::Divergent<self::Divergent<core::int>>>).call() as{TypeError,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<core::int>>>;
}
static method main() → dynamic {}
constants {
#C1 = null
#C2 = #catchError
#C3 = <core::Type*>[]
#C4 = #test
#C5 = #whenComplete
#C6 = <dynamic>[]
#C7 = core::_ImmutableMap<core::Symbol*, dynamic> {_kvPairs:#C6}
#C8 = #timeout
#C9 = #onTimeout
#C10 = #then
#C11 = #onError
#C12 = #asStream
}

View file

@ -0,0 +1,8 @@
import 'dart:async';
class Divergent<T> implements Future<Divergent<Divergent<T>>> {
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
test() async {}
main() {}

View file

@ -0,0 +1,8 @@
import 'dart:async';
class Divergent<T> implements Future<Divergent<Divergent<T>>> {
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
main() {}
test() async {}

View file

@ -0,0 +1,66 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/issue42546.dart:14:58: Error: A value of type 'Divergent<int>' can't be returned from an async function with return type 'Future<Divergent<Divergent<Divergent<int>>>>'.
// - 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
// - 'Future' is from 'dart:async'.
// Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
// ^
//
// pkg/front_end/testcases/nnbd/issue42546.dart:14:75: Error: A value of type 'Future<Divergent<Divergent<Divergent<int>>>>' can't be assigned to a variable of type 'Future<Divergent<Divergent<int>>>'.
// - 'Future' is from 'dart:async'.
// - 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
// Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
// ^
//
import self as self;
import "dart:core" as core;
import "dart:async" as asy;
import "dart:async";
class Divergent<T extends core::Object? = dynamic> extends core::Object implements asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>> {
synthetic constructor •() → self::Divergent<self::Divergent::T%>
: super core::Object::•()
;
method noSuchMethod(core::Invocation invocation) → dynamic
return super.{core::Object::noSuchMethod}(invocation);
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ catchError(core::Function onError, {(core::Object) →? core::bool test = #C1}) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C2, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[onError]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C4: test}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ whenComplete(() → FutureOr<void>action) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C5, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[action]), core::Map::unmodifiable<core::Symbol*, dynamic>(#C7))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ timeout(core::Duration timeLimit, {generic-covariant-impl () →? FutureOr<self::Divergent<self::Divergent<self::Divergent::T%>>>onTimeout = #C1}) → asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C8, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[timeLimit]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C9: onTimeout}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<self::Divergent::T%>>>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ then<R extends core::Object? = dynamic>((self::Divergent<self::Divergent<self::Divergent::T%>>) → FutureOr<self::Divergent::then::R%>onValue, {core::Function? onError = #C1}) → asy::Future<self::Divergent::then::R%>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C10, 0, core::List::unmodifiable<core::Type*>(<core::Type*>[self::Divergent::then::R%]), core::List::unmodifiable<dynamic>(<dynamic>[onValue]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C11: onError}))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::Divergent::then::R%>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ asStream() → asy::Stream<self::Divergent<self::Divergent<self::Divergent::T%>>>
return this.{self::Divergent::noSuchMethod}(new core::_InvocationMirror::_withType(#C12, 0, #C3, #C6, core::Map::unmodifiable<core::Symbol*, dynamic>(#C7))) as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Stream<self::Divergent<self::Divergent<self::Divergent::T%>>>;
}
static method test() → dynamic async {
asy::Future<self::Divergent<self::Divergent<core::int>>> x = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd/issue42546.dart:14:75: Error: A value of type 'Future<Divergent<Divergent<Divergent<int>>>>' can't be assigned to a variable of type 'Future<Divergent<Divergent<int>>>'.
- 'Future' is from 'dart:async'.
- 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
^" in (() → asy::Future<self::Divergent<self::Divergent<self::Divergent<core::int>>>> async => let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/nnbd/issue42546.dart:14:58: Error: A value of type 'Divergent<int>' can't be returned from an async function with return type 'Future<Divergent<Divergent<Divergent<int>>>>'.
- 'Divergent' is from 'pkg/front_end/testcases/nnbd/issue42546.dart'.
- 'Future' is from 'dart:async'.
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())();
^" in new self::Divergent::•<core::int>() as{TypeError,ForNonNullableByDefault} self::Divergent<self::Divergent<self::Divergent<core::int>>>).call() as{TypeError,ForNonNullableByDefault} asy::Future<self::Divergent<self::Divergent<core::int>>>;
}
static method main() → dynamic {}
constants {
#C1 = null
#C2 = #catchError
#C3 = <core::Type*>[]
#C4 = #test
#C5 = #whenComplete
#C6 = <dynamic>[]
#C7 = core::_ImmutableMap<core::Symbol*, dynamic> {_kvPairs:#C6}
#C8 = #timeout
#C9 = #onTimeout
#C10 = #then
#C11 = #onError
#C12 = #asStream
}

View file

@ -172,6 +172,7 @@ instantiate_to_bound/non_simple_generic_function_in_bound_regress: RuntimeError
late_lowering/covariant_late_field: TypeCheckError
nnbd/covariant_late_field: TypeCheckError
nnbd/issue41180: RuntimeError # Strong mode runtime checking fails due to mixed strong mode.
nnbd/issue42546: TypeCheckError
nnbd/nullable_object_access: TypeCheckError
nnbd/nullable_receiver: TypeCheckError
nnbd/potentially_nullable_access: TypeCheckError

View file

@ -170,6 +170,7 @@ instantiate_to_bound/non_simple_generic_function_in_bound_regress: RuntimeError
late_lowering/covariant_late_field: TypeCheckError
nnbd/covariant_late_field: TypeCheckError
nnbd/issue41180: RuntimeError
nnbd/issue42546: TypeCheckError
nnbd/nullable_object_access: TypeCheckError
nnbd/nullable_receiver: TypeCheckError
nnbd/potentially_nullable_access: TypeCheckError

View file

@ -60,6 +60,7 @@ general_nnbd_opt_out/unsound_promotion: TypeCheckError
general_nnbd_opt_out/void_methods: RuntimeError
late_lowering/covariant_late_field: TypeCheckError
nnbd/covariant_late_field: TypeCheckError
nnbd/issue42546: TypeCheckError
nnbd/nullable_object_access: TypeCheckError
nnbd/nullable_receiver: TypeCheckError
nnbd/potentially_nullable_access: TypeCheckError

View file

@ -29,7 +29,7 @@ FutureOr<Object> Function() test3 = () async {
return v;
// ^
// [analyzer] unspecified
// [cfe] A value of type 'Future<void>' can't be returned from an async function with return type 'FutureOr<Object>'.
// [cfe] A value of type 'Future<void>' can't be returned from an async function with return type 'Future<Object>'.
};
// Inferred return type of function literal is `Future<void>`, no error.

View file

@ -22,7 +22,7 @@ FutureOr<String> Function() test2 = () async {
return v;
// ^
// [analyzer] unspecified
// [cfe] A value of type 'int' can't be returned from an async function with return type 'FutureOr<String>'.
// [cfe] A value of type 'int' can't be returned from an async function with return type 'Future<String>'.
};
void main() {

View file

@ -22,7 +22,7 @@ FutureOr<String> Function() test2 = () async {
return v;
// ^
// [analyzer] unspecified
// [cfe] A value of type 'Future<int>' can't be returned from an async function with return type 'FutureOr<String>'.
// [cfe] A value of type 'Future<int>' can't be returned from an async function with return type 'Future<String>'.
};
void main() {

View file

@ -22,7 +22,7 @@ FutureOr<String> Function() test2 = () async {
return v;
// ^
// [analyzer] unspecified
// [cfe] A value of type 'FutureOr<int>' can't be returned from an async function with return type 'FutureOr<String>'.
// [cfe] A value of type 'FutureOr<int>' can't be returned from an async function with return type 'Future<String>'.
};
void main() {

View file

@ -22,7 +22,7 @@ FutureOr<String> Function() test2 = () async {
return v;
// ^
// [analyzer] unspecified
// [cfe] A value of type 'Future<Future<String>>' can't be returned from an async function with return type 'FutureOr<String>'.
// [cfe] A value of type 'Future<Future<String>>' can't be returned from an async function with return type 'Future<String>'.
};
void main() {

View file

@ -23,7 +23,7 @@ FutureOr<Null> Function() test2 = () async {
return v;
// ^
// [analyzer] unspecified
// [cfe] A value of type 'Future<void>' can't be returned from an async function with return type 'FutureOr<Null>'.
// [cfe] A value of type 'Future<void>' can't be returned from an async function with return type 'Future<Null>'.
};
void main() {

View file

@ -23,7 +23,7 @@ FutureOr<Null> Function() test2 = () async {
return v;
// ^
// [analyzer] unspecified
// [cfe] A value of type 'FutureOr<void>' can't be returned from an async function with return type 'FutureOr<Null>'.
// [cfe] A value of type 'FutureOr<void>' can't be returned from an async function with return type 'Future<Null>'.
};
void main() {

View file

@ -33,7 +33,7 @@ test() async {
Divergent<Divergent<int>> x = await new Divergent<int>(); //# 09: runtime error
Future<Divergent<Divergent<int>>> f() async => new Divergent<int>(); //# 10: ok
Future<Divergent<Divergent<int>>> f() async { return new Divergent<int>(); } //# 11: ok
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())(); //# 12: runtime error
Future<Divergent<Divergent<int>>> x = (() async => new Divergent<int>())(); //# 12: compile-time error
}
main() {