-
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.
Issue #996: tests for Generic functions as type arguments and bounds …
…added.
- Loading branch information
Showing
16 changed files
with
752 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_t01.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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef void TEST<T extends void Function<TT>()>(); | ||
void testme<T extends void Function<TT>()>() {} | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_t02.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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef void TEST<T extends TT Function<TT>()>(); | ||
void testme<T extends TT Function<TT>()>() {} | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313, 45322 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef void TEST<T extends void Function<TT>(TT t)>(); | ||
void testme<T extends void Function<TT>(TT t)>() {} | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_t04.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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313, 45322 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef void TEST<T extends TT Function<TT>(TT t)>(); | ||
void testme<T extends TT Function<TT>(TT t)>() {} | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_t05.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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef T TEST<T extends void Function<TT>()>(); | ||
T testme<T extends void Function<TT>()>() => throw "Hello"; | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_t06.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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef T TEST<T extends TT Function<TT>()>(); | ||
T testme<T extends TT Function<TT>()>() => throw "Hello!"; | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_t07.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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313, 45322 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef T TEST<T extends void Function<TT>(TT t)>(); | ||
T testme<T extends void Function<TT>(TT t)>() => throw "Hello!"; | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
47 changes: 47 additions & 0 deletions
47
LanguageFeatures/Generic-functions-as-type-args/typedef2_t08.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,47 @@ | ||
/* | ||
* Copyright (c) 2021, 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 Allow generic function types as type arguments and bounds | ||
* | ||
* The language disallows generic function types as type arguments and bounds. | ||
* | ||
* late List<T Function<T>(T)> idFunctions; // INVALID. | ||
* var callback = [foo<T>(T value) => value]; // Inferred as above, then invalid. | ||
* late S Function<S extends T Function<T>(T)>(S) f; // INVALID. | ||
* | ||
* We remove that restriction, so a type argument and a bound can be a generic | ||
* function type. | ||
* | ||
* This requires no new syntax, and in some cases only the removal of a single | ||
* check. There might be some platforms where the implementation currently | ||
* assumes that generic function types cannot occur as the value of type | ||
* variables (an proof-of-concept attempt hit an assert in the VM). Such | ||
* assumptions will need to be flushed out with tests and fixed. | ||
* | ||
* Because we already infer List<T Function<T>(T)> in the code above, this | ||
* change will not affect type inference, it will just make the inferred type | ||
* not be an error afterwards. | ||
* | ||
* We do not expect the removal of this restriction to affect the feasibility of | ||
* type inference. After all, it's already possible to have a generic function | ||
* type occurring covariantly in a type argument, like List<T Function<T>(T) | ||
* Function()>. | ||
* @description Checks that generic function can be a function type alias | ||
* argument and bound. | ||
* @Issue 45313, 45322 | ||
* @author [email protected] | ||
*/ | ||
//--enable-experiment=generic-metadata | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
typedef T TEST<T extends void Function<TT>(TT t)>(); | ||
T testme<T extends void Function<TT>(TT t)>() => throw "Hello!"; | ||
|
||
main() { | ||
TEST t = testme; | ||
Expect.isTrue(testme is TEST); | ||
} |
Oops, something went wrong.