smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

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

Open kubukoz opened this issue 1 year ago • 2 comments

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 avatar Jan 06 '24 02:01 kubukoz

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

structure Hello {
  @required productArity: Integer
}

because it actually does compile.

kubukoz avatar Jan 06 '24 02:01 kubukoz

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

Baccata avatar Jan 08 '24 13:01 Baccata