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

Abierto
#4,157 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@ayush00git ya está trabajando en esto.

Desde el 9/10/2026.

  • #4159 de @ayush00git — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
grpc, swift
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Java
Estrellas
4.6k
Forks
470
Merge medio
9 h 28 min
PR fusionados (30 d)
33

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/fory

Todos los issues de apache/fory

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.