diff --git a/Language/Functions/Type_of_a_Function/return_type_t01.dart b/Language/Functions/Type_of_a_Function/return_type_t01.dart index 06d115801f..2fef3a26d6 100644 --- a/Language/Functions/Type_of_a_Function/return_type_t01.dart +++ b/Language/Functions/Type_of_a_Function/return_type_t01.dart @@ -2,11 +2,13 @@ // 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. -/// @assertion If a function does not declare a return type explicitly, its -/// return type is dynamic, unless it is a constructor function, in which case -/// its return type is the immediately enclosing class. -/// @description Checks that return type is dynamic. Static checker should not -/// cause static warnings because type Dynamic has every method and property. +/// @assertion If a function declaration does not declare a return type +/// explicitly, its return type is dynamic, unless it is a constructor, in which +/// case it is not considered to have a return type, or it is a setter or +/// operator []=, in which case its return type is void +/// +/// @description Checks that if a function declaration does not declare a return +/// type then its return type is dynamic /// @author msyabro import "../../../Utils/expect.dart"; diff --git a/Language/Functions/Type_of_a_Function/return_type_t02.dart b/Language/Functions/Type_of_a_Function/return_type_t02.dart index 526938561f..03a9da320e 100644 --- a/Language/Functions/Type_of_a_Function/return_type_t02.dart +++ b/Language/Functions/Type_of_a_Function/return_type_t02.dart @@ -2,9 +2,11 @@ // 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. -/// @assertion If a function does not declare a return type explicitly, its -/// return type is dynamic, unless it is a constructor function, in which case -/// its return type is the immediately enclosing class. +/// @assertion If a function declaration does not declare a return type +/// explicitly, its return type is dynamic, unless it is a constructor, in which +/// case it is not considered to have a return type, or it is a setter or +/// operator []=, in which case its return type is void +/// /// @description Checks that return type of a constructor is the immediately /// enclosing class. /// @author ngl@unipro.ru diff --git a/Language/Functions/Type_of_a_Function/return_type_t03.dart b/Language/Functions/Type_of_a_Function/return_type_t03.dart new file mode 100644 index 0000000000..aa0a3a0307 --- /dev/null +++ b/Language/Functions/Type_of_a_Function/return_type_t03.dart @@ -0,0 +1,24 @@ +// Copyright (c) 2023, 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. + +/// @assertion If a function declaration does not declare a return type +/// explicitly, its return type is dynamic, unless it is a constructor, in which +/// case it is not considered to have a return type, or it is a setter or +/// operator []=, in which case its return type is void +/// +/// @description Checks that return type of a constructor is the immediately +/// enclosing class. +/// @author sgrekhov22@gmail.com + +import "../../../Utils/static_type_helper.dart"; + +class C { + C() {} + C.n() {} +} + +main() { + C.new.expectStaticType>(); + C.n.expectStaticType>(); +} diff --git a/Language/Functions/async_return_type_t01.dart b/Language/Functions/async_return_type_t01.dart index eb4c62036d..8b47365f50 100644 --- a/Language/Functions/async_return_type_t01.dart +++ b/Language/Functions/async_return_type_t01.dart @@ -2,15 +2,13 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked async may not be assigned to Future. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked async is not a supertype of Future for some type T /// /// @description Check that it is a compile time error, if the declared -/// return type of asynchronous function may not be assigned to Future. -/// +/// return type of asynchronous function may not be assigned to `Future`. /// @author a.semenov@unipro.ru - int f() async { //^ // [analyzer] unspecified diff --git a/Language/Functions/async_return_type_t02.dart b/Language/Functions/async_return_type_t02.dart index 0370346937..ddf897608f 100644 --- a/Language/Functions/async_return_type_t02.dart +++ b/Language/Functions/async_return_type_t02.dart @@ -2,15 +2,13 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked async may not be assigned to Future. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked async is not a supertype of Future for some type T /// /// @description Check that it is no compile time error, if the declared -/// return type of asynchronous function may not be assigned to Future but is -/// void. +/// return type of asynchronous function is `void`. /// @author a.semenov@unipro.ru - void h() async { return null; } diff --git a/Language/Functions/async_return_type_t03.dart b/Language/Functions/async_return_type_t03.dart index a27e9d37d9..b2e51b0705 100644 --- a/Language/Functions/async_return_type_t03.dart +++ b/Language/Functions/async_return_type_t03.dart @@ -2,12 +2,11 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked async may not be assigned to Future. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked async is not a supertype of Future for some type T /// /// @description Check that it is no compile time error, if the declared -/// return type of asynchronous function may be assigned to Future. -/// +/// return type of asynchronous function is a supertype of `Future` /// @author a.semenov@unipro.ru import 'dart:async'; @@ -16,11 +15,16 @@ dynamic a() async { return 'a'; } -Future b() async { +Future b() async { return 'b'; } +Future c() async { + return throw 1; +} + main() { a(); b(); + print(c); } diff --git a/Language/Functions/generator_return_type_t01.dart b/Language/Functions/generator_return_type_t01.dart index bc40e3be50..baf71407c3 100644 --- a/Language/Functions/generator_return_type_t01.dart +++ b/Language/Functions/generator_return_type_t01.dart @@ -2,18 +2,13 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. -/// -/// @description Check that it is a compile error, if the declared -/// return type of synchronous generator function may not be assigned -/// to Iterable. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked sync* is not a supertype of Iterable for some type T /// +/// @description Check that it is a compile error, if the declared return type +/// of synchronous generator function is not a supertype of `Iterable` /// @author a.semenov@unipro.ru - int f() sync* { } //^ // [analyzer] unspecified diff --git a/Language/Functions/generator_return_type_t02.dart b/Language/Functions/generator_return_type_t02.dart index bbfa61841a..55c3457fa1 100644 --- a/Language/Functions/generator_return_type_t02.dart +++ b/Language/Functions/generator_return_type_t02.dart @@ -2,18 +2,14 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked sync* or async* is void. /// -/// @description Check that it is a compile error, if the declared -/// return type of synchronous generator function may not be assigned -/// to Iterable but is void. +/// @description Check that it is a compile error, if the declared return type +/// of synchronous generator function is `void`. /// @issue 32192 /// @author a.semenov@unipro.ru - void h() sync* { } //^ // [analyzer] unspecified diff --git a/Language/Functions/generator_return_type_t03.dart b/Language/Functions/generator_return_type_t03.dart index 53c5cbc21b..5cd0214aa4 100644 --- a/Language/Functions/generator_return_type_t03.dart +++ b/Language/Functions/generator_return_type_t03.dart @@ -2,17 +2,13 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked sync* is not a supertype of Iterable for some type T /// -/// @description Check that it is no compile error, if the declared -/// return type of synchronous generator function may be assigned -/// to Iterable. +/// @description Check that it is no compile error, if the declared return type +/// of synchronous generator function is supertype of `Iterable`. /// @author a.semenov@unipro.ru - Iterable c() sync* { } main() { diff --git a/Language/Functions/generator_return_type_t04.dart b/Language/Functions/generator_return_type_t04.dart index 90916ce3b3..6bf030117f 100644 --- a/Language/Functions/generator_return_type_t04.dart +++ b/Language/Functions/generator_return_type_t04.dart @@ -2,18 +2,13 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. -/// -/// @description Check that it is no compile error, if the declared -/// return type of synchronous generator function may be assigned -/// to Iterable. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked sync* is not a supertype of Iterable for some type T /// +/// @description Check that it is no compile error, if the declared return type +/// of synchronous generator function is supertype of `Iterable`. /// @author a.semenov@unipro.ru - dynamic a() sync* { } Iterable b() sync* { } diff --git a/Language/Functions/generator_return_type_t05.dart b/Language/Functions/generator_return_type_t05.dart index 6f67800ade..79b6f623e1 100644 --- a/Language/Functions/generator_return_type_t05.dart +++ b/Language/Functions/generator_return_type_t05.dart @@ -2,17 +2,13 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. -/// -/// @description Check that it is a compile error, if the declared -/// return type of a function marked async* may not be assigned to Stream. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked async* is not a supertype of Stream for some type T /// +/// @description Check that it is a compile error, if the declared return type +/// of a function marked `async*` is not a supertype of Stream /// @author a.semenov@unipro.ru - int f() async* { } //^ // [analyzer] unspecified diff --git a/Language/Functions/generator_return_type_t06.dart b/Language/Functions/generator_return_type_t06.dart index 36cf005c59..2df4888430 100644 --- a/Language/Functions/generator_return_type_t06.dart +++ b/Language/Functions/generator_return_type_t06.dart @@ -2,18 +2,14 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked sync* or async* is void. /// -/// @description Check that it is a compile error, if the declared -/// return type of a function marked async* may not be assigned to Stream but is -/// void. +/// @description Check that it is a compile error, if the declared return type +/// of a function marked `async*` is `void`. /// @issue 32192 /// @author a.semenov@unipro.ru - void h() async* { } //^ // [analyzer] unspecified diff --git a/Language/Functions/generator_return_type_t07.dart b/Language/Functions/generator_return_type_t07.dart index 748fa72bcd..340c4f789e 100644 --- a/Language/Functions/generator_return_type_t07.dart +++ b/Language/Functions/generator_return_type_t07.dart @@ -2,13 +2,11 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked async* is not a supertype of Stream for some type T /// -/// @description Check that it is no compile error, if the declared -/// return type of a function marked async* may be assigned to Stream. +/// @description Check that it is no compile error, if the declared return type +/// of a function marked `async*` is a supertype of `Stream`. /// @author a.semenov@unipro.ru import 'dart:async'; diff --git a/Language/Functions/generator_return_type_t08.dart b/Language/Functions/generator_return_type_t08.dart index d84baffaaf..dd0a41e4c3 100644 --- a/Language/Functions/generator_return_type_t08.dart +++ b/Language/Functions/generator_return_type_t08.dart @@ -2,14 +2,11 @@ // 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. -/// @assertion It is a static warning if the declared return type of a function -/// marked sync* may not be assigned to Iterable. It is a static warning if -/// the declared return type of a function marked async* may not be assigned -/// to Stream. -/// -/// @description Check that it is no compile error, if the declared -/// return type of a function marked async* may be assigned to Stream. +/// @assertion It is a compile-time error if the declared return type of a +/// function marked async* is not a supertype of Stream for some type T /// +/// @description Check that it is no compile error, if the declared return type +/// of a function marked `async*` is a supertype of `Stream`. /// @author a.semenov@unipro.ru import 'dart:async';