Skip to content

Commit

Permalink
Merge pull request #407 from Workiva/fix-type-mismatch-on-FunctionTool
Browse files Browse the repository at this point in the history
Fix type mismatch between `DevTool.fromFunction()` and `DevTool.run()`
  • Loading branch information
rmconsole3-wf authored Jun 9, 2023
2 parents 13e0bea + a7c664e commit 23b74ae
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dart_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [ 2.18.7, stable ]
sdk: [ 2.18.7 ] # TODO: re-add stable when compatible
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
sdk: 2.18.7

- id: install
name: Install dependencies
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.0.1

- Fix type mismatch between the expected return type of the function passed to
`DevTool.fromFunction()` and the `DevTool.run()` method. The updated type is
more permissive and so should not be breaking.

## 4.0.0

- Migrated to null safety. The new SDK minimum is 2.18
Expand Down
2 changes: 1 addition & 1 deletion lib/src/dart_dev_tool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class DevTool {
DevTool();

factory DevTool.fromFunction(
FutureOr<int>? Function(DevToolExecutionContext context) function,
FutureOr<int?> Function(DevToolExecutionContext context) function,
{ArgParser? argParser}) =>
FunctionTool(function, argParser: argParser);

Expand Down
4 changes: 2 additions & 2 deletions lib/src/tools/function_tool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import '../utils/assert_no_positional_args_nor_args_after_separator.dart';
/// Use [DevTool.fromFunction] to create [FunctionTool] instances.
class FunctionTool extends DevTool {
FunctionTool(
FutureOr<int>? Function(DevToolExecutionContext context) function,
FutureOr<int?> Function(DevToolExecutionContext context) function,
{ArgParser? argParser})
: _argParser = argParser,
_function = function;

final FutureOr<int>? Function(DevToolExecutionContext context) _function;
final FutureOr<int?> Function(DevToolExecutionContext context) _function;

// ---------------------------------------------------------------------------
// DevTool Overrides
Expand Down

0 comments on commit 23b74ae

Please sign in to comment.