Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Fix newly surface errors after cleanup #64

Merged
merged 2 commits into from
Apr 21, 2020

Conversation

natebosch
Copy link
Contributor

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
Contributor 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:
https://github.com/dart-lang/stack_trace/blob/90ea41ba0788c1f8c3ce1cf61a6c00f9d4d13a81/lib/src/stack_zone_specification.dart#L14

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
Contributor 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
Contributor 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
mosuem pushed a commit to dart-lang/tools that referenced this pull request Dec 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

4 participants