Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix newly surface errors after cleanup #64

Merged
merged 2 commits into from Apr 21, 2020

Conversation

natebosch
Copy link
Member

Some cleanup on the master branch surfaced new static errors in the
migration branch.

  • More variable types (from var with an uninitialized variable)
    requires additional late or additional casts.
  • Use on Object catch when the static type of the error shouldn't by
    dynamic since we now disallow implicit casts from dynamic. These
    won't be necessary after a catch with no on clause gets an inferred
    type of Object instead of dynamic.
  • Add some more ! in places where adding more argument types which
    were previously implicit dynamic caused less dynamic throughout the
    body of a function.

Some cleanup on the master branch surfaced new static errors in the
migration branch.

- More variable types (from `var` with an uninitialized variable)
  requires additional `late` or additional casts.
- Use `on Object catch` when the static type of the error shouldn't by
  `dynamic` since we now disallow implicit casts from `dynamic`. These
  won't be necessary after a catch with no `on` clause gets an inferred
  type of `Object` instead of `dynamic`.
- Add some more `!` in places where adding more argument types which
  were previously implicit dynamic caused less dynamic throughout the
  body of a function.
@@ -73,7 +73,7 @@ class Chain implements StackTrace {
///
/// If [callback] returns a value, it will be returned by [capture] as well.
static T capture<T>(T Function() callback,
{void Function(Object error, Chain)? onError,
{void Function(dynamic error, Chain)? onError,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify why this should be dynamic now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was dynamic before. I changed it in https://github.com/dart-lang/stack_trace/pull/62/files#diff-9e567343197420b24b39f009a31aa65aR76

My hope was that it wasn't breaking since any Function(dynamic, Chain) can work as a Function(Object, Chain), but I didn't change it in the typedef here:

typedef _ChainHandler = void Function(dynamic error, Chain chain);

I can either change that one too, or I need to change this one back to dynamic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that errors can't be null any more afaik, I think changing the typedef seems reasonable? Or is there some other reason we don't want to change that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I'll go with that

natebosch added a commit that referenced this pull request Apr 17, 2020
See #64 (comment)

Enable and fix the lint `avoid_private_typedef_functions`.
natebosch added a commit that referenced this pull request Apr 17, 2020
See #64 (comment)

Enable and fix the lint `avoid_private_typedef_functions`.
@natebosch
Copy link
Member Author

Back to Object. PTAL.

Once I get this in I'll do another merge from master and get things settled.

@natebosch natebosch merged commit c43458c into null_safety Apr 21, 2020
@natebosch natebosch deleted the null-safety-implicit-cast-dynamic branch April 21, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants