Skip to content

Commit 23b74ae

Browse files
Merge pull request #407 from Workiva/fix-type-mismatch-on-FunctionTool
Fix type mismatch between `DevTool.fromFunction()` and `DevTool.run()`
2 parents 13e0bea + a7c664e commit 23b74ae

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.github/workflows/dart_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
sdk: [ 2.18.7, stable ]
18+
sdk: [ 2.18.7 ] # TODO: re-add stable when compatible
1919
steps:
2020
- uses: actions/checkout@v3
2121
- uses: dart-lang/setup-dart@v1
@@ -44,7 +44,7 @@ jobs:
4444
- uses: actions/checkout@v3
4545
- uses: dart-lang/setup-dart@v1
4646
with:
47-
sdk: stable
47+
sdk: 2.18.7
4848

4949
- id: install
5050
name: Install dependencies

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 4.0.1
4+
5+
- Fix type mismatch between the expected return type of the function passed to
6+
`DevTool.fromFunction()` and the `DevTool.run()` method. The updated type is
7+
more permissive and so should not be breaking.
8+
39
## 4.0.0
410

511
- Migrated to null safety. The new SDK minimum is 2.18

lib/src/dart_dev_tool.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ abstract class DevTool {
1212
DevTool();
1313

1414
factory DevTool.fromFunction(
15-
FutureOr<int>? Function(DevToolExecutionContext context) function,
15+
FutureOr<int?> Function(DevToolExecutionContext context) function,
1616
{ArgParser? argParser}) =>
1717
FunctionTool(function, argParser: argParser);
1818

lib/src/tools/function_tool.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import '../utils/assert_no_positional_args_nor_args_after_separator.dart';
1313
/// Use [DevTool.fromFunction] to create [FunctionTool] instances.
1414
class FunctionTool extends DevTool {
1515
FunctionTool(
16-
FutureOr<int>? Function(DevToolExecutionContext context) function,
16+
FutureOr<int?> Function(DevToolExecutionContext context) function,
1717
{ArgParser? argParser})
1818
: _argParser = argParser,
1919
_function = function;
2020

21-
final FutureOr<int>? Function(DevToolExecutionContext context) _function;
21+
final FutureOr<int?> Function(DevToolExecutionContext context) _function;
2222

2323
// ---------------------------------------------------------------------------
2424
// DevTool Overrides

0 commit comments

Comments
 (0)