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

Proposed change in code for the "|" operator overload in SftpFileOpenMode #80

Open
gaddlord opened this issue May 27, 2023 · 0 comments

Comments

@gaddlord
Copy link

gaddlord commented May 27, 2023

Currently we have the declaration

class SftpFileOpenMode {
  ...
 operator |(SftpFileOpenMode other) => SftpFileOpenMode._(flag | other.flag);
}

The operator overload is declared without providing the desired return type which defaults it to dynamic.

This emits an error when compiled with Dart 3.0 "The argument 'dynamic' can't be assigned to the parameter type 'SftpFileOpenMode.'" in the sample below:

final file = await sftp.open(remoteFilename, mode: SftpFileOpenMode.create | SftpFileOpenMode.write);

The way to solve that is to specify explictly the return type of the "|" operator to be SftpFileOpenMode as shown in the sample below:

class SftpFileOpenMode {
  ...
  SftpFileOpenMode operator |(SftpFileOpenMode other) => SftpFileOpenMode._(flag | other.flag);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant