disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/
Other
340 stars 68 forks source link

Names of members of scala.Product, scala.Serializable should be escaped in case classes #1346

Open kubukoz opened 6 months ago

kubukoz commented 6 months ago

There's probably more to this, but here's a minimal example of what's wrong:

namespace input

structure Hello {
  productArity: String
}

Output:

[error] -- [E164] Declaration Error: /Users/kubukoz/projects/demos/target/scala-3.3.1/src_managed/main/scala/input/Hello.scala:10:23 
[error] 10 |final case class Hello(productArity: Option[String] = None)
[error]    |                       ^
[error]    |   error overriding method productArity in trait Product of type => Int;
[error]    |     value productArity of type Option[String] has incompatible type
[error]    |

This will probably be similar to collisions with java.lang.Object methods: https://github.com/disneystreaming/smithy4s/commit/56a3cd09688f6c9cfd550ee03dcf504573e3fef1.

kubukoz commented 6 months ago

BTW this may be outright dangerous if you use anything that relies on productArity:

structure Hello {
  @required productArity: Integer
}

because it actually does compile.

Baccata commented 6 months ago

yeah, let's add those to the reserved words list, like we did for methods coming java.lang.Object