[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 个 reaction 已指派 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 分钟
30 天内合并 PR
33

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/fory 的其他 Issue

查看 apache/fory 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。