Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional shared objects #124

Closed
sebastian-peter opened this issue Jan 17, 2022 · 3 comments
Closed

Optional shared objects #124

sebastian-peter opened this issue Jan 17, 2022 · 3 comments
Labels

Comments

@sebastian-peter
Copy link
Contributor

Describe the bug
Shared objects that are marked as optional in a comment, are not wrapped in scala.Option.
In Java with --java:optionals enabled, java.util.Optional is not used either.

To Reproduce

#@define
Shared {
  c: string
  d: int
}

example {
  # @optional
  a: Shared
}

results in:

final case class Example(
  a : ExperimentsConfig.Shared
)

Expected behavior

final case class Example(
  a : scala.Option[ExperimentsConfig.Shared]
)

Target language(s):

  • Scala
  • Java

Additional context
In ScalaGen.scala:95, the type is wrapped in scala.Option. This type is not used in ScalaGen.scala:109, where the type name for ObjectRefTypes is generated.
Analogously in JavaGen.scala:98 for Java generation.
(at least, this is my interpretation of what is happening)

@carueda
Copy link
Owner

carueda commented Jan 17, 2022

Thanks for entering this issue, which has actually been known for a while as noted in the readme:

Note: current support is in terms of the referenced object always being required. In other words, a: "Struct?", as an example, is not supported. Also, the @define annotation is only supported for objects and enumerations (see below), not for a basic types or lists.

But good to have an explicit entry in the tracker for when the time comes to address it. Thanks again.

@carueda carueda added the bug label Jan 17, 2022
@sebastian-peter
Copy link
Contributor Author

sebastian-peter commented Jan 17, 2022

I missed that note, my bad. This issue could then be considered a feature request rather than a bug.
Anyhow, since our project would benefit from this, I'll gladly look into this if I can find some time this week.
(Unless, of course, there's deeper reasons for leaving this as it is.)

@carueda
Copy link
Owner

carueda commented Jan 18, 2022

Thanks for the offer! And, let's keep it as a bug because full support (as with any other type) is certainly what makes more sense. The current limitations have been due to time constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants