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

Đang mở
#4,157 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@ayush00git đang làm issue này rồi.

Từ ngày 9/10/2026.

  • #4159 của @ayush00git — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
grpc, swift
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
4.6k
Fork
470
Merge trung bình
9 giờ 28 phút
Pull request đã merge (30 ngày)
33

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/fory

Tất cả issue của apache/fory

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.