-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Dart 2 SDK Tests vs flutter test --preview-dart-2 #15900
Comments
Have you tried running with |
@DanTup Good call -- I should have included that run as well. I get the same results:
|
Sorry to ping on this one again -- trying to get my stuff Dart 2 ready! Does anyone have any insights into this issue? |
@brianegan I had a go at reproing this, but failed to restore packages:
I'm likely on a later flutter. Have you tried on either the new beta update this week, or on master to see if it might already fixed? I think there have been a lot of fixes since the first beta. (I don't think you use it, but in VS Code you can check both master and beta out and quickly switch between them from the status bar). |
@DanTup I ran into this issue on master as well, but worth giving it another shot. Thanks for the help! |
FWIW, I suspect the error is the correct behaviour and the Dart VM is incorrect (or outdated). If you define a function as taking |
@DanTup Yep, that's definitely what I'm trying to suss out... basically, I think I have the wrong base types going on. I was using The exact function that's throwing the error is this one: // User defines the type of Action they want to handle
class ReducerBinding<State, Action> { /* Omitted for brevity */ }
// Function takes in a list of ReducerBindings with different types of actions handled.
// It returns a function of the correct signature: (State, dynamic) => State
//
// I've tried using both ReducerBinding<State, dynamic> and ReducerBinding<State, Object>
// but neither works. I think this is where the problem lies: I need to use the proper
// base type for all Objects for Dart 2.
Reducer<State> combineTypedReducers<State>(
List<ReducerBinding<State, dynamic>> bindings) {
return (State state, dynamic action) {
return bindings.fold(state, (currentState, binder) {
if (binder.handlesAction(action)) {
return binder.reducer(state, action);
} else {
return currentState;
}
});
};
} |
I don't know a lot about how this works, but can you not use generic type args so the types all match up everywhere? (it if works, you'll get extra type safety you didn't have with dynamic) |
In this case, that's not possible. An I think it boils down to this: I'm wondering why |
Ok, got it working by shuffling some code around, but still curious if this might be a bug. Thanks for the help @DanTup :) The problem in the end turned out to be this line:
However, if I pass the
Gonna close this one out and see if I can create a simplified test case for the Dart 2 Repo. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
I've been running into a funny issue updating the Redux library for Dart 2. Since Redux does not depend on Flutter, I generally run tests in a pure dart environment. When I run tests using the Dart 2 SDKs, all tests pass. When I run tests in a Flutter environment, I run into errors.
I'm not sure if these are accurate type errors that are no longer supported by Dart 2, or if there's some bug in Flutter, but it's a bit confusing since the tests pass using the Dart 2 SDK by itself.
Steps to Reproduce
redux-flutter-test
branchcombine_test
using the Dart SDK provided by flutter, everything worksflutter test --preview-dart-2
and I get type errorsLogs
Run
flutter analyze
and attach any output of that command also.Flutter Doctor
The text was updated successfully, but these errors were encountered: