microsoft / typespec

https://typespec.io/
MIT License
4.51k stars 216 forks source link

[Bug][http-client-java] azure-json serialization, constant property in parent class cannot be accessed from child class #5028

Open XiaofeiCao opened 1 week ago

XiaofeiCao commented 1 week ago

Describe the bug

unbranded generated code: https://github.com/joseharriaga/openai-in-typespec/commit/25c0126d909b43c8ce6971d905f7551e6e8110ff

tsp source: https://github.com/joseharriaga/openai-in-typespec/blob/main/.typespec/fine-tuning/models.tsp#L310-L311 base model: https://github.com/joseharriaga/openai-in-typespec/blob/main/.typespec/chat/models.tsp#L448

Current thought:

  1. This property should be package-private, since all models are in the same package(no models-sub-packages configuration)
  2. Access through getter?

Reproduction

see above

Checklist

weidongxu-microsoft commented 1 day ago

Seems we can treat it just the same way as a read-only property (duplicate it in subclass?).

weidongxu-microsoft commented 16 hours ago

Or do we need to generate the @Override public String getRole() in subclass? If we don't generate it, seems the problem gone?