Skip to content

Conversation

@sidepelican
Copy link
Collaborator

以下のようなコードにおいて、重複したシンボルが生成されるという問題があります。

struct Foo {
  struct JSON {}}

FooのTS側JSON型としてFoo_JSONが。
Foo.JSONのTS側Entity型としてFoo_JSONが生成され、衝突します。

この問題の原因は、ネームスペース結合の記号とJSON型のSuffix結合の記号が同一の_であることだと思います。
片方の結合に用いる記号を変更することで回避ができます。

もちろん、Swift側の型名で_$が使われていた場合に似たような壊れが起こると思いますが、それは特殊なケースなので諦めます。


public static func jsonName(entityName: String) -> String {
return "\(entityName)_JSON"
return "\(entityName)$JSON"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本質的な変更はここだけです

@sidepelican sidepelican requested a review from omochi April 25, 2024 02:48
Copy link
Owner

@omochi omochi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます
小さな変更に対して見かけの差分が派手だ。

@omochi omochi merged commit a3c1246 into main Apr 25, 2024
@omochi omochi deleted the json-suffix branch April 25, 2024 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants