Skip to content

[pigeon] Support ExistentialAny in Swift code #147347

@yuukiw00w

Description

@yuukiw00w

Use case

When -enable-upcoming-feature ExistentialAny is set to Other Swift Flags, it results in a build error.
This feature is said to default to true in Swift 7, and 'any' needs to be appended to Existential Type.
Since the code generated by the current pigeon does not append 'any' to the Existential Type, I would like it to be modified to include this.

In issue( #147283 ), I provided sample code and a feature request that also covers ExistentialAny.
However, this issue will focus specifically on addressing errors related to ExistentialAny.

By generating code from the following code using pigeon and simply adding -enable-upcoming-feature ExistentialAny to Other Swift Flags, you can see a build error.

import 'package:pigeon/pigeon.dart';

@ConfigurePigeon(
  PigeonOptions(
    dartOut: 'lib/generated/sample.g.dart',
    dartOptions: DartOptions(),
    swiftOut: 'ios/Runner/generated/Sample.g.swift',
    swiftOptions: SwiftOptions(),
  ),
)
@HostApi()
abstract class SampleApi {
  @async
  Sample fetchSampleAsync(SampleParameter parameter);

  Sample fetchSampleSync(SampleParameter parameter);

  @async
  Object? objectSampleAsync(Object? parameter);

  Object? objectSampleSync(Object? parameter);
}

@FlutterApi()
abstract class CallFromNative {
  Sample fetchSample(SampleParameter parameter);

  Object? objectSample(Object? parameter);
}

class Sample {
  Sample({
    required this.text,
    required this.id,
  });
  final String text;
  final int id;
}

class SampleParameter {
  SampleParameter({
    required this.text,
    required this.id,
  });
  final String text;
  final int id;
}

I will provide a link to a sample repository to easily confirm the build error.
https://github.com/yuukiw00w/ExistentialAnySampleForFlutter

Proposal

Please add 'any' to the Existential Type as in the following Pull Request.
https://github.com/yuukiw00w/ExistentialAnySampleForFlutter/pull/1/files

From what I've confirmed, 'any' needs to be added to 'Error' (in completion handler), to the 'api' in the 'setUp' function and FlutterBinaryMessenger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.team-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