-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
83 additions
and
86 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
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 |
---|---|---|
|
@@ -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 [email protected] | ||
|
24 changes: 24 additions & 0 deletions
24
Language/Functions/Type_of_a_Function/return_type_t03.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,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 [email protected] | ||
import "../../../Utils/static_type_helper.dart"; | ||
|
||
class C { | ||
C() {} | ||
C.n() {} | ||
} | ||
|
||
main() { | ||
C.new.expectStaticType<Exactly<C Function()>>(); | ||
C.n.expectStaticType<Exactly<C Function()>>(); | ||
} |
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 |
---|---|---|
|
@@ -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<T> 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 [email protected] | ||
|
||
int f() async { | ||
//^ | ||
// [analyzer] unspecified | ||
|
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 |
---|---|---|
|
@@ -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<T> 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 [email protected] | ||
|
||
void h() async { | ||
return null; | ||
} | ||
|
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 |
---|---|---|
|
@@ -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<T> 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<T>` | ||
/// @author [email protected] | ||
import 'dart:async'; | ||
|
@@ -16,11 +15,16 @@ dynamic a() async { | |
return 'a'; | ||
} | ||
|
||
Future b() async { | ||
Future<String> b() async { | ||
return 'b'; | ||
} | ||
|
||
Future<Never> c() async { | ||
return throw 1; | ||
} | ||
|
||
main() { | ||
a(); | ||
b(); | ||
print(c); | ||
} |
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 |
---|---|---|
|
@@ -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<T> 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<T>` | ||
/// @author [email protected] | ||
|
||
int f() sync* { } | ||
//^ | ||
// [analyzer] unspecified | ||
|
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 |
---|---|---|
|
@@ -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 [email protected] | ||
|
||
void h() sync* { } | ||
//^ | ||
// [analyzer] unspecified | ||
|
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 |
---|---|---|
|
@@ -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<T> 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 [email protected] | ||
|
||
Iterable c() sync* { } | ||
|
||
main() { | ||
|
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 |
---|---|---|
|
@@ -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<T> 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 [email protected] | ||
|
||
dynamic a() sync* { } | ||
|
||
Iterable b() sync* { } | ||
|
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 |
---|---|---|
|
@@ -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<T> 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<T> | ||
/// @author [email protected] | ||
|
||
int f() async* { } | ||
//^ | ||
// [analyzer] unspecified | ||
|
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 |
---|---|---|
|
@@ -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 [email protected] | ||
|
||
void h() async* { } | ||
//^ | ||
// [analyzer] unspecified | ||
|
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 |
---|---|---|
|
@@ -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<T> 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<T>`. | ||
/// @author [email protected] | ||
import 'dart:async'; | ||
|
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 |
---|---|---|
|
@@ -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<T> 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<T>`. | ||
/// @author [email protected] | ||
import 'dart:async'; | ||
|