[Compiler][Swift] recursive unions with any poison the Equatable cache; nested ref targets stay value structs; keyword packages produce invalid identifiers

オープン
#4,157 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@ayush00git がすでに取り組んでいます。

2026年10月9日 から。

  • #4159 @ayush00git による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
grpc, swift
領域
compilers

調査の方向性

The issue names three separate Swift codegen bugs: a poisoned Equatable cache for recursive unions, wrong ref-target lineage for nested messages, and keyword package names producing invalid backtick identifiers. Start with the repro in the issue (union Wrapper and message Node) and the Equatable cache in the Swift generator, then check the package-component escaping that joins with _. Pull request #4159 is already open against this issue, so coordinate with it before starting. Done means the generated Swift for the repro compiles and the nested ref and Any package cases produce valid identifiers.

索引モデルが issue の本文から書いたものです。

説明

Three Swift codegen bugs in the compiler:

  1. When a union's Equatable check visits a message that refers back to the in-progress union, the message's provisional result is cached permanently. A later case of the same union (e.g. any) overturns the union's answer, but the poisoned cache entry survives, so the message is emitted as struct Node: Equatable whose only stored property is non-Equatable — the generated Swift does not compile.

Repro:

union Wrapper { string note; Node node; any extra; }
message Node { Wrapper wrapper = 1; }
  1. ref-target resolution inside nested messages uses the wrong parent lineage, so a ref field in a nested message cannot resolve a sibling nested type; the target silently stays a value struct instead of being promoted to final class, breaking reference identity / wire-level ref-flag compatibility with Java and C++ (the identical top-level shape is promoted correctly).

  2. Package components are backtick-escaped individually and then joined with _, so a package like any (PascalCase Any, a Swift keyword) produces identifiers like `Any`_User and gRPC symbols like `Any`_GreeterProvider — backticks embedded mid-identifier are invalid Swift, so flatten-style and service output for such packages does not compile.

主要言語
Java
スター
4.6k
フォーク
470
平均マージ
9時間 28分
マージ済み PR(30日)
33

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/fory のほかの issue

apache/fory の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。