Skip to content

[pigeon] Generated swift code throws compile time error on recursive types #145175

@LouiseHsu

Description

@LouiseHsu

Given an input of

  SKPaymentTransactionMessage({
    required this.payment,
    required this.transactionState,
    this.originalTransaction,
    this.transactionTimeStamp,
    this.transactionIdentifier,
    this.error,
  });

  final SKPaymentMessage payment;
  final SKPaymentTransactionStateMessage transactionState;
  final SKPaymentTransactionMessage? originalTransaction;
  final double? transactionTimeStamp;
  final String? transactionIdentifier;
  final SKErrorMessage? error;
}

Pigeon generates

struct SKPaymentTransactionMessage {
  var payment: SKPaymentMessage
  var transactionState: SKPaymentTransactionStateMessage
  var originalTransaction: SKPaymentTransactionMessage? = nil
  var transactionTimeStamp: Double? = nil
  var transactionIdentifier: String? = nil
  var error: SKErrorMessage? = nil
  \\ ...

However, the swift compiler will complain that
Value type 'SKPaymentTransactionMessage' cannot have a stored property that recursively contains it

I ran into this issue while I was trying to migrate in_app_purchase_storekit from obj-c to swift, and didn't have issues with recursive types when generating obj-c.

cc @stuartmorgan

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: 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