Skip to content

[pigeon] If both plugin and app uses Swift for generating code, extension for FlutterError make project not buildable. #147371

@bc-lee

Description

@bc-lee

Steps to reproduce

  1. Create a new Flutter app and plugin, respectively.
  2. Add pigeon to both projects and generate Swift code.
  3. Add an extension to FlutterError in both projects (extension FlutterError: Swift.Error {}).
  4. Try to build the project.

Expected results

The project should build successfully.

Actual results

error: redundant conformance of 'FlutterError' to protocol 'Error'

Code sample

Check out https://github.com/bc-lee/demo-flutter-pigeon-swift.git with
aca044733e3f624a14ab6cd40851c733b519f1e7 commit.
Failing GitHub Action: Link

Analysis

Requiring users to add extension FlutterError: Swift.Error {} was due to #137057. However, even with that workaround, the project still remains unbuildable.

The root cause of this issue is that Swift has much stricter type system than Objective-C. For example, protocol conformance must not be redundant[1].

We need better solution to avoid this issue. I'm working on a PR to fix this issue.

[1] https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations/#Protocol-Conformance-Must-Not-Be-Redundant

Flutter Doctor output

Doctor output
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-KR)
    • Flutter version 3.19.6 on channel stable at /Users/leebc/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (8 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions