smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

`@adt`, mixins and optionality changes don't play well

Open kubukoz opened this issue 1 year ago • 3 comments

If you apply a mixin to a shape, and then make an inherited field required, smithy4s will not generate an extends with that mixin.

However, if such a shape is part of and @adt union, the union still has extends. This results in a compilation error:

$version: "2"

namespace input

@mixin
structure HasName {
    name: String
}

structure Person with [HasName] {
    @required
    $name
}

@smithy4s.meta#adt
union U {
    p: Person
}
[error] /Users/kubukoz/projects/demos/target/scala-2.13/src_managed/main/scala/input/U.scala:31:27: incompatible type in overriding
[error] def name: Option[String] (defined in trait HasName);
[error]  found   : String
[error]  required: Option[String]
[error]   final case class Person(name: String) extends U {
[error]                           ^
[error] one error found

Checked in 0.18.15.

kubukoz avatar Mar 25 '24 18:03 kubukoz

Slightly related / worth considering the relation to: #1312

kubukoz avatar Mar 25 '24 18:03 kubukoz

Don't have much thoughts about it besides "let's fix it I guess ?"

Baccata avatar Mar 25 '24 18:03 Baccata

yeah, I think we're gonna have to extend #425.

kubukoz avatar Mar 25 '24 20:03 kubukoz

Looks like it's closed in #1510

kubukoz avatar May 09 '24 19:05 kubukoz