Skip to content

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

@gaddlord

Description

@gaddlord

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions