diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d5a7d18e..07b7e3be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Thank you! # 0.18.25 * Fixes an issue in which refinements wouldn't work on custom simple shapes (newtypes) (see [#1595](https://github.com/disneystreaming/smithy4s/pull/1595)) +* Fixes an issue in which union members targetting Unit would fail to compile when used as traits (see [#1600](https://github.com/disneystreaming/smithy4s/pull/1600)). +* Make the `transform` method in generated `*Gen` algebras final. This should make it possible to derive e.g. `FunctorK` instances in cats-tagless automatically (see [#1588](https://github.com/disneystreaming/smithy4s/pull/1588)). # 0.18.24 diff --git a/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala b/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala index f41e79195..31ef79bf9 100644 --- a/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala +++ b/modules/bootstrapped/src/generated/com/amazonaws/dynamodb/DynamoDB.scala @@ -49,7 +49,7 @@ trait DynamoDBGen[F[_, _, _, _, _]] { */ def listTables(exclusiveStartTableName: Option[TableName] = None, limit: Option[ListTablesInputLimit] = None): F[ListTablesInput, DynamoDBOperation.ListTablesError, ListTablesOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[DynamoDBGen[F]] = Transformation.of[DynamoDBGen[F]](this) + final def transform: Transformation.PartiallyApplied[DynamoDBGen[F]] = Transformation.of[DynamoDBGen[F]](this) } object DynamoDBGen extends Service.Mixin[DynamoDBGen, DynamoDBOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/benchmark/BenchmarkService.scala b/modules/bootstrapped/src/generated/smithy4s/benchmark/BenchmarkService.scala index e1ef29d50..e61d8593f 100644 --- a/modules/bootstrapped/src/generated/smithy4s/benchmark/BenchmarkService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/benchmark/BenchmarkService.scala @@ -17,7 +17,7 @@ trait BenchmarkServiceGen[F[_, _, _, _, _]] { def createObject(key: String, bucketName: String, payload: S3Object): F[CreateObjectInput, Nothing, Unit, Nothing, Nothing] def sendString(key: String, bucketName: String, body: String): F[SendStringInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[BenchmarkServiceGen[F]] = Transformation.of[BenchmarkServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[BenchmarkServiceGen[F]] = Transformation.of[BenchmarkServiceGen[F]](this) } object BenchmarkServiceGen extends Service.Mixin[BenchmarkServiceGen, BenchmarkServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/BrandService.scala b/modules/bootstrapped/src/generated/smithy4s/example/BrandService.scala index 5f9d88637..3ccfb0e5b 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/BrandService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/BrandService.scala @@ -16,7 +16,7 @@ trait BrandServiceGen[F[_, _, _, _, _]] { def addBrands(brands: Option[List[String]] = None): F[AddBrandsInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[BrandServiceGen[F]] = Transformation.of[BrandServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[BrandServiceGen[F]] = Transformation.of[BrandServiceGen[F]](this) } object BrandServiceGen extends Service.Mixin[BrandServiceGen, BrandServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedService.scala b/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedService.scala index 189dfd330..6d000b0ac 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/DeprecatedService.scala @@ -18,7 +18,7 @@ trait DeprecatedServiceGen[F[_, _, _, _, _]] { @deprecated(message = "N/A", since = "N/A") def deprecatedOperation(): F[Unit, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[DeprecatedServiceGen[F]] = Transformation.of[DeprecatedServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[DeprecatedServiceGen[F]] = Transformation.of[DeprecatedServiceGen[F]](this) } object DeprecatedServiceGen extends Service.Mixin[DeprecatedServiceGen, DeprecatedServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/DiscriminatedService.scala b/modules/bootstrapped/src/generated/smithy4s/example/DiscriminatedService.scala index 8c7cb21d2..a5a25f430 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/DiscriminatedService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/DiscriminatedService.scala @@ -15,7 +15,7 @@ trait DiscriminatedServiceGen[F[_, _, _, _, _]] { def testDiscriminated(key: String): F[TestDiscriminatedInput, Nothing, TestDiscriminatedOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[DiscriminatedServiceGen[F]] = Transformation.of[DiscriminatedServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[DiscriminatedServiceGen[F]] = Transformation.of[DiscriminatedServiceGen[F]](this) } object DiscriminatedServiceGen extends Service.Mixin[DiscriminatedServiceGen, DiscriminatedServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/DummyService.scala b/modules/bootstrapped/src/generated/smithy4s/example/DummyService.scala index e498cc779..d5648f46b 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/DummyService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/DummyService.scala @@ -22,7 +22,7 @@ trait DummyServiceGen[F[_, _, _, _, _]] { def dummyHostPrefix(label1: String, label2: String, label3: HostLabelEnum): F[HostLabelInput, Nothing, Unit, Nothing, Nothing] def dummyPath(str: String, int: Int, ts1: Timestamp, ts2: Timestamp, ts3: Timestamp, ts4: Timestamp, b: Boolean, ie: Numbers): F[PathParams, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[DummyServiceGen[F]] = Transformation.of[DummyServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[DummyServiceGen[F]] = Transformation.of[DummyServiceGen[F]](this) } object DummyServiceGen extends Service.Mixin[DummyServiceGen, DummyServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/EmptyService.scala b/modules/bootstrapped/src/generated/smithy4s/example/EmptyService.scala index a2c14736b..be71cd940 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/EmptyService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/EmptyService.scala @@ -12,7 +12,7 @@ trait EmptyServiceGen[F[_, _, _, _, _]] { self => - def transform: Transformation.PartiallyApplied[EmptyServiceGen[F]] = Transformation.of[EmptyServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[EmptyServiceGen[F]] = Transformation.of[EmptyServiceGen[F]](this) } object EmptyServiceGen extends Service.Mixin[EmptyServiceGen, EmptyServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala index 798bfdb62..ffdfb8b6f 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingService.scala @@ -18,7 +18,7 @@ trait ErrorHandlingServiceGen[F[_, _, _, _, _]] { def errorHandlingOperation(in: Option[String] = None): F[ErrorHandlingOperationInput, ErrorHandlingServiceOperation.ErrorHandlingOperationError, ErrorHandlingOperationOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ErrorHandlingServiceGen[F]] = Transformation.of[ErrorHandlingServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[ErrorHandlingServiceGen[F]] = Transformation.of[ErrorHandlingServiceGen[F]](this) } object ErrorHandlingServiceGen extends Service.Mixin[ErrorHandlingServiceGen, ErrorHandlingServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala index a2c0da768..96c145144 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ErrorHandlingServiceExtraErrors.scala @@ -19,7 +19,7 @@ trait ErrorHandlingServiceExtraErrorsGen[F[_, _, _, _, _]] { def extraErrorOperation(in: Option[String] = None): F[ExtraErrorOperationInput, ErrorHandlingServiceExtraErrorsOperation.ExtraErrorOperationError, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ErrorHandlingServiceExtraErrorsGen[F]] = Transformation.of[ErrorHandlingServiceExtraErrorsGen[F]](this) + final def transform: Transformation.PartiallyApplied[ErrorHandlingServiceExtraErrorsGen[F]] = Transformation.of[ErrorHandlingServiceExtraErrorsGen[F]](this) } object ErrorHandlingServiceExtraErrorsGen extends Service.Mixin[ErrorHandlingServiceExtraErrorsGen, ErrorHandlingServiceExtraErrorsOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/FooService.scala b/modules/bootstrapped/src/generated/smithy4s/example/FooService.scala index 52ba798dc..ed2fccdcf 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/FooService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/FooService.scala @@ -23,7 +23,7 @@ trait FooServiceGen[F[_, _, _, _, _]] { */ def getFoo(): F[Unit, Nothing, GetFooOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[FooServiceGen[F]] = Transformation.of[FooServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[FooServiceGen[F]] = Transformation.of[FooServiceGen[F]](this) } object FooServiceGen extends Service.Mixin[FooServiceGen, FooServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/HasUnionUnitCaseTrait.scala b/modules/bootstrapped/src/generated/smithy4s/example/HasUnionUnitCaseTrait.scala new file mode 100644 index 000000000..f96e4fa4c --- /dev/null +++ b/modules/bootstrapped/src/generated/smithy4s/example/HasUnionUnitCaseTrait.scala @@ -0,0 +1,17 @@ +package smithy4s.example + +import smithy4s.Hints +import smithy4s.Newtype +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.schema.Schema.bijection +import smithy4s.schema.Schema.string + +object HasUnionUnitCaseTrait extends Newtype[String] { + val id: ShapeId = ShapeId("smithy4s.example", "HasUnionUnitCaseTrait") + val hints: Hints = Hints( + smithy4s.example.UnionTraitWithUnitCase.UCase.widen, + ).lazily + val underlyingSchema: Schema[String] = string.withId(id).addHints(hints) + implicit val schema: Schema[HasUnionUnitCaseTrait] = bijection(underlyingSchema, asBijection) +} diff --git a/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala b/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala index 96c88feed..15b069a7d 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/KVStore.scala @@ -21,7 +21,7 @@ trait KVStoreGen[F[_, _, _, _, _]] { def put(key: String, value: String): F[KeyValue, KVStoreOperation.PutError, Unit, Nothing, Nothing] def delete(key: String): F[Key, KVStoreOperation.DeleteError, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[KVStoreGen[F]] = Transformation.of[KVStoreGen[F]](this) + final def transform: Transformation.PartiallyApplied[KVStoreGen[F]] = Transformation.of[KVStoreGen[F]](this) } object KVStoreGen extends Service.Mixin[KVStoreGen, KVStoreOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/Library.scala b/modules/bootstrapped/src/generated/smithy4s/example/Library.scala index 15597ce1b..9ccf90dad 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/Library.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/Library.scala @@ -18,7 +18,7 @@ trait LibraryGen[F[_, _, _, _, _]] { def getBook(): F[Unit, Nothing, Unit, Nothing, Nothing] def buyBook(): F[Unit, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[LibraryGen[F]] = Transformation.of[LibraryGen[F]](this) + final def transform: Transformation.PartiallyApplied[LibraryGen[F]] = Transformation.of[LibraryGen[F]](this) } object LibraryGen extends Service.Mixin[LibraryGen, LibraryOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala b/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala index 00978821a..297a632d4 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/NameCollision.scala @@ -19,7 +19,7 @@ trait NameCollisionGen[F[_, _, _, _, _]] { def myOp(): F[Unit, NameCollisionOperation.MyOpError, Unit, Nothing, Nothing] def endpoint(): F[Unit, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[NameCollisionGen[F]] = Transformation.of[NameCollisionGen[F]](this) + final def transform: Transformation.PartiallyApplied[NameCollisionGen[F]] = Transformation.of[NameCollisionGen[F]](this) } object NameCollisionGen extends Service.Mixin[NameCollisionGen, NameCollisionOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ObjectCollision.scala b/modules/bootstrapped/src/generated/smithy4s/example/ObjectCollision.scala index 9de4e60ee..b1165cf9c 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ObjectCollision.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ObjectCollision.scala @@ -24,7 +24,7 @@ trait ObjectCollisionGen[F[_, _, _, _, _]] { def _toString(): F[Unit, Nothing, Unit, Nothing, Nothing] def _wait(): F[Unit, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ObjectCollisionGen[F]] = Transformation.of[ObjectCollisionGen[F]](this) + final def transform: Transformation.PartiallyApplied[ObjectCollisionGen[F]] = Transformation.of[ObjectCollisionGen[F]](this) } object ObjectCollisionGen extends Service.Mixin[ObjectCollisionGen, ObjectCollisionOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala b/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala index eaadab04b..2a636dd80 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ObjectService.scala @@ -27,7 +27,7 @@ trait ObjectServiceGen[F[_, _, _, _, _]] { */ def getObject(key: ObjectKey, bucketName: BucketName): F[GetObjectInput, ObjectServiceOperation.GetObjectError, GetObjectOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ObjectServiceGen[F]] = Transformation.of[ObjectServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[ObjectServiceGen[F]] = Transformation.of[ObjectServiceGen[F]](this) } object ObjectServiceGen extends Service.Mixin[ObjectServiceGen, ObjectServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/PackedInputsService.scala b/modules/bootstrapped/src/generated/smithy4s/example/PackedInputsService.scala index 30834b45e..a0d084e90 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/PackedInputsService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/PackedInputsService.scala @@ -16,7 +16,7 @@ trait PackedInputsServiceGen[F[_, _, _, _, _]] { def packedInputOperation(input: PackedInput): F[PackedInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[PackedInputsServiceGen[F]] = Transformation.of[PackedInputsServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[PackedInputsServiceGen[F]] = Transformation.of[PackedInputsServiceGen[F]](this) } object PackedInputsServiceGen extends Service.Mixin[PackedInputsServiceGen, PackedInputsServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala b/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala index 21a8c652e..0d4ecdbb1 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/PizzaAdminService.scala @@ -32,7 +32,7 @@ trait PizzaAdminServiceGen[F[_, _, _, _, _]] { def headRequest(): F[Unit, Nothing, HeadRequestOutput, Nothing, Nothing] def noContentRequest(): F[Unit, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[PizzaAdminServiceGen[F]] = Transformation.of[PizzaAdminServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[PizzaAdminServiceGen[F]] = Transformation.of[PizzaAdminServiceGen[F]](this) } object PizzaAdminServiceGen extends Service.Mixin[PizzaAdminServiceGen, PizzaAdminServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/RecursiveInputService.scala b/modules/bootstrapped/src/generated/smithy4s/example/RecursiveInputService.scala index 9c6dcc710..7697788f8 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/RecursiveInputService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/RecursiveInputService.scala @@ -16,7 +16,7 @@ trait RecursiveInputServiceGen[F[_, _, _, _, _]] { def recursiveInputOperation(hello: Option[RecursiveInput] = None): F[RecursiveInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[RecursiveInputServiceGen[F]] = Transformation.of[RecursiveInputServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[RecursiveInputServiceGen[F]] = Transformation.of[RecursiveInputServiceGen[F]](this) } object RecursiveInputServiceGen extends Service.Mixin[RecursiveInputServiceGen, RecursiveInputServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/ServiceWithNullsAndDefaults.scala b/modules/bootstrapped/src/generated/smithy4s/example/ServiceWithNullsAndDefaults.scala index 5fce0b700..1a96cdf5b 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/ServiceWithNullsAndDefaults.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/ServiceWithNullsAndDefaults.scala @@ -17,7 +17,7 @@ trait ServiceWithNullsAndDefaultsGen[F[_, _, _, _, _]] { def defaultNullsOperation(input: DefaultNullsOperationInput): F[DefaultNullsOperationInput, Nothing, DefaultNullsOperationOutput, Nothing, Nothing] def timestampOperation(input: TimestampOperationInput): F[TimestampOperationInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ServiceWithNullsAndDefaultsGen[F]] = Transformation.of[ServiceWithNullsAndDefaultsGen[F]](this) + final def transform: Transformation.PartiallyApplied[ServiceWithNullsAndDefaultsGen[F]] = Transformation.of[ServiceWithNullsAndDefaultsGen[F]](this) } object ServiceWithNullsAndDefaultsGen extends Service.Mixin[ServiceWithNullsAndDefaultsGen, ServiceWithNullsAndDefaultsOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/StreamedObjects.scala b/modules/bootstrapped/src/generated/smithy4s/example/StreamedObjects.scala index e6839fc7c..cde6022bc 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/StreamedObjects.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/StreamedObjects.scala @@ -18,7 +18,7 @@ trait StreamedObjectsGen[F[_, _, _, _, _]] { def putStreamedObject(key: String): F[PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing] def getStreamedObject(key: String): F[GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob] - def transform: Transformation.PartiallyApplied[StreamedObjectsGen[F]] = Transformation.of[StreamedObjectsGen[F]](this) + final def transform: Transformation.PartiallyApplied[StreamedObjectsGen[F]] = Transformation.of[StreamedObjectsGen[F]](this) } object StreamedObjectsGen extends Service.Mixin[StreamedObjectsGen, StreamedObjectsOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/UnionTraitWithUnitCase.scala b/modules/bootstrapped/src/generated/smithy4s/example/UnionTraitWithUnitCase.scala new file mode 100644 index 000000000..b40bb9c3b --- /dev/null +++ b/modules/bootstrapped/src/generated/smithy4s/example/UnionTraitWithUnitCase.scala @@ -0,0 +1,67 @@ +package smithy4s.example + +import UnionTraitWithUnitCase.UCaseAlt +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.Schema.bijection +import smithy4s.schema.Schema.recursive +import smithy4s.schema.Schema.string +import smithy4s.schema.Schema.union + +sealed trait UnionTraitWithUnitCase extends scala.Product with scala.Serializable { self => + @inline final def widen: UnionTraitWithUnitCase = this + def $ordinal: Int + + object project { + def u: Option[UnionTraitWithUnitCase.UCase.type] = UCaseAlt.project.lift(self) + def s: Option[String] = UnionTraitWithUnitCase.SCase.alt.project.lift(self).map(_.s) + } + + def accept[A](visitor: UnionTraitWithUnitCase.Visitor[A]): A = this match { + case value: UnionTraitWithUnitCase.UCase.type => visitor.u(value) + case value: UnionTraitWithUnitCase.SCase => visitor.s(value.s) + } +} +object UnionTraitWithUnitCase extends ShapeTag.Companion[UnionTraitWithUnitCase] { + + def u(): UnionTraitWithUnitCase = UnionTraitWithUnitCase.UCase + def s(s: String): UnionTraitWithUnitCase = SCase(s) + + val id: ShapeId = ShapeId("smithy4s.example", "unionTraitWithUnitCase") + + val hints: Hints = Hints( + smithy.api.Trait(selector = None, structurallyExclusive = None, conflicts = None, breakingChanges = None), + ).lazily + + case object UCase extends UnionTraitWithUnitCase { final def $ordinal: Int = 0 } + private val UCaseAlt = Schema.constant(UnionTraitWithUnitCase.UCase).oneOf[UnionTraitWithUnitCase]("u").addHints(hints) + final case class SCase(s: String) extends UnionTraitWithUnitCase { final def $ordinal: Int = 1 } + + object SCase { + val hints: Hints = Hints.empty + val schema: Schema[UnionTraitWithUnitCase.SCase] = bijection(string.addHints(hints), UnionTraitWithUnitCase.SCase(_), _.s) + val alt = schema.oneOf[UnionTraitWithUnitCase]("s") + } + + trait Visitor[A] { + def u(value: UnionTraitWithUnitCase.UCase.type): A + def s(value: String): A + } + + object Visitor { + trait Default[A] extends Visitor[A] { + def default: A + def u(value: UnionTraitWithUnitCase.UCase.type): A = default + def s(value: String): A = default + } + } + + implicit val schema: Schema[UnionTraitWithUnitCase] = recursive(union( + UCaseAlt, + UnionTraitWithUnitCase.SCase.alt, + ){ + _.$ordinal + }.withId(id).addHints(hints)) +} diff --git a/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala b/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala index 4015fa5f1..d0aba4cf6 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/Weather.scala @@ -23,7 +23,7 @@ trait WeatherGen[F[_, _, _, _, _]] { def getForecast(cityId: CityId): F[GetForecastInput, Nothing, GetForecastOutput, Nothing, Nothing] def listCities(nextToken: Option[String] = None, pageSize: Option[Int] = None): F[ListCitiesInput, Nothing, ListCitiesOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[WeatherGen[F]] = Transformation.of[WeatherGen[F]](this) + final def transform: Transformation.PartiallyApplied[WeatherGen[F]] = Transformation.of[WeatherGen[F]](this) } object WeatherGen extends Service.Mixin[WeatherGen, WeatherOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/aws/MyThing.scala b/modules/bootstrapped/src/generated/smithy4s/example/aws/MyThing.scala index 807b7a8fa..6beba2804 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/aws/MyThing.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/aws/MyThing.scala @@ -12,7 +12,7 @@ trait MyThingGen[F[_, _, _, _, _]] { self => - def transform: Transformation.PartiallyApplied[MyThingGen[F]] = Transformation.of[MyThingGen[F]](this) + final def transform: Transformation.PartiallyApplied[MyThingGen[F]] = Transformation.of[MyThingGen[F]](this) } object MyThingGen extends Service.Mixin[MyThingGen, MyThingOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/collision/ReservedNameService.scala b/modules/bootstrapped/src/generated/smithy4s/example/collision/ReservedNameService.scala index eb4652255..197accd7a 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/collision/ReservedNameService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/collision/ReservedNameService.scala @@ -19,7 +19,7 @@ trait ReservedNameServiceGen[F[_, _, _, _, _]] { def map(value: scala.collection.immutable.Map[smithy4s.example.collision.String, smithy4s.example.collision.String]): F[MapInput, Nothing, Unit, Nothing, Nothing] def option(value: scala.Option[smithy4s.example.collision.String] = None): F[OptionInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ReservedNameServiceGen[F]] = Transformation.of[ReservedNameServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[ReservedNameServiceGen[F]] = Transformation.of[ReservedNameServiceGen[F]](this) } object ReservedNameServiceGen extends Service.Mixin[ReservedNameServiceGen, ReservedNameServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/greet/GreetService.scala b/modules/bootstrapped/src/generated/smithy4s/example/greet/GreetService.scala index fdca3d8e4..3f4b90f6a 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/greet/GreetService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/greet/GreetService.scala @@ -15,7 +15,7 @@ trait GreetServiceGen[F[_, _, _, _, _]] { def greet(name: String): F[GreetInput, Nothing, GreetOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[GreetServiceGen[F]] = Transformation.of[GreetServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[GreetServiceGen[F]] = Transformation.of[GreetServiceGen[F]](this) } object GreetServiceGen extends Service.Mixin[GreetServiceGen, GreetServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala b/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala index a678023e3..59e2159eb 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/guides/auth/HelloWorldAuthService.scala @@ -20,7 +20,7 @@ trait HelloWorldAuthServiceGen[F[_, _, _, _, _]] { def sayWorld(): F[Unit, HelloWorldAuthServiceOperation.SayWorldError, World, Nothing, Nothing] def healthCheck(): F[Unit, HelloWorldAuthServiceOperation.HealthCheckError, HealthCheckOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[HelloWorldAuthServiceGen[F]] = Transformation.of[HelloWorldAuthServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[HelloWorldAuthServiceGen[F]] = Transformation.of[HelloWorldAuthServiceGen[F]](this) } object HelloWorldAuthServiceGen extends Service.Mixin[HelloWorldAuthServiceGen, HelloWorldAuthServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/guides/hello/HelloWorldService.scala b/modules/bootstrapped/src/generated/smithy4s/example/guides/hello/HelloWorldService.scala index 32fdf7701..c14524aac 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/guides/hello/HelloWorldService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/guides/hello/HelloWorldService.scala @@ -16,7 +16,7 @@ trait HelloWorldServiceGen[F[_, _, _, _, _]] { def sayWorld(): F[Unit, Nothing, World, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[HelloWorldServiceGen[F]] = Transformation.of[HelloWorldServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[HelloWorldServiceGen[F]] = Transformation.of[HelloWorldServiceGen[F]](this) } object HelloWorldServiceGen extends Service.Mixin[HelloWorldServiceGen, HelloWorldServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala b/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala index 1ef9acb62..5069303bf 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/hello/HelloWorldService.scala @@ -18,7 +18,7 @@ trait HelloWorldServiceGen[F[_, _, _, _, _]] { def hello(name: String, town: Option[String] = None): F[Person, HelloWorldServiceOperation.HelloError, Greeting, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[HelloWorldServiceGen[F]] = Transformation.of[HelloWorldServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[HelloWorldServiceGen[F]] = Transformation.of[HelloWorldServiceGen[F]](this) } object HelloWorldServiceGen extends Service.Mixin[HelloWorldServiceGen, HelloWorldServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala b/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala index 3c6d39aa5..67b4248d4 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/imp/ImportService.scala @@ -21,7 +21,7 @@ trait ImportServiceGen[F[_, _, _, _, _]] { def importOperation(): F[Unit, ImportServiceOperation.ImportOperationError, OpOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ImportServiceGen[F]] = Transformation.of[ImportServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[ImportServiceGen[F]] = Transformation.of[ImportServiceGen[F]](this) } object ImportServiceGen extends Service.Mixin[ImportServiceGen, ImportServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/package.scala b/modules/bootstrapped/src/generated/smithy4s/example/package.scala index a914f9cf4..568c337a0 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/package.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/package.scala @@ -66,6 +66,7 @@ package object example { type ExtraData = smithy4s.example.ExtraData.Type type FancyList = smithy4s.example.FancyList.Type type FreeForm = smithy4s.example.FreeForm.Type + type HasUnionUnitCaseTrait = smithy4s.example.HasUnionUnitCaseTrait.Type type Ingredients = smithy4s.example.Ingredients.Type /** @param member * listFoo diff --git a/modules/bootstrapped/src/generated/smithy4s/example/product/ExampleService.scala b/modules/bootstrapped/src/generated/smithy4s/example/product/ExampleService.scala index b9c15a600..4a09388e5 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/product/ExampleService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/product/ExampleService.scala @@ -16,7 +16,7 @@ trait ExampleServiceGen[F[_, _, _, _, _]] { def exampleOperation(a: String): F[ExampleOperationInput, Nothing, ExampleOperationOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ExampleServiceGen[F]] = Transformation.of[ExampleServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[ExampleServiceGen[F]] = Transformation.of[ExampleServiceGen[F]](this) } trait ExampleServiceProductGen[F[_, _, _, _, _]] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/reservedNameOverride/ReservedNameOverrideService.scala b/modules/bootstrapped/src/generated/smithy4s/example/reservedNameOverride/ReservedNameOverrideService.scala index 5f67990e6..549ab9968 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/reservedNameOverride/ReservedNameOverrideService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/reservedNameOverride/ReservedNameOverrideService.scala @@ -16,7 +16,7 @@ trait ReservedNameOverrideServiceGen[F[_, _, _, _, _]] { def setOp(set: Set): F[SetOpInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[ReservedNameOverrideServiceGen[F]] = Transformation.of[ReservedNameOverrideServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[ReservedNameOverrideServiceGen[F]] = Transformation.of[ReservedNameOverrideServiceGen[F]](this) } object ReservedNameOverrideServiceGen extends Service.Mixin[ReservedNameOverrideServiceGen, ReservedNameOverrideServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala b/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala index 518557b0a..81dc62293 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/test/HelloService.scala @@ -21,7 +21,7 @@ trait HelloServiceGen[F[_, _, _, _, _]] { def listen(): F[Unit, Nothing, Unit, Nothing, Nothing] def testPath(path: String): F[TestPathInput, Nothing, Unit, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[HelloServiceGen[F]] = Transformation.of[HelloServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[HelloServiceGen[F]] = Transformation.of[HelloServiceGen[F]](this) } object HelloServiceGen extends Service.Mixin[HelloServiceGen, HelloServiceOperation] { diff --git a/modules/bootstrapped/src/generated/smithy4s/example/test/HelloWorldService.scala b/modules/bootstrapped/src/generated/smithy4s/example/test/HelloWorldService.scala index e1135ef1c..603453601 100644 --- a/modules/bootstrapped/src/generated/smithy4s/example/test/HelloWorldService.scala +++ b/modules/bootstrapped/src/generated/smithy4s/example/test/HelloWorldService.scala @@ -15,7 +15,7 @@ trait HelloWorldServiceGen[F[_, _, _, _, _]] { def hello(name: String): F[HelloInput, Nothing, HelloOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[HelloWorldServiceGen[F]] = Transformation.of[HelloWorldServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[HelloWorldServiceGen[F]] = Transformation.of[HelloWorldServiceGen[F]](this) } object HelloWorldServiceGen extends Service.Mixin[HelloWorldServiceGen, HelloWorldServiceOperation] { diff --git a/modules/bootstrapped/src/generated/weather/WeatherService.scala b/modules/bootstrapped/src/generated/weather/WeatherService.scala index 3258c14e9..c118be625 100644 --- a/modules/bootstrapped/src/generated/weather/WeatherService.scala +++ b/modules/bootstrapped/src/generated/weather/WeatherService.scala @@ -15,7 +15,7 @@ trait WeatherServiceGen[F[_, _, _, _, _]] { def getWeather(city: String): F[GetWeatherInput, Nothing, GetWeatherOutput, Nothing, Nothing] - def transform: Transformation.PartiallyApplied[WeatherServiceGen[F]] = Transformation.of[WeatherServiceGen[F]](this) + final def transform: Transformation.PartiallyApplied[WeatherServiceGen[F]] = Transformation.of[WeatherServiceGen[F]](this) } object WeatherServiceGen extends Service.Mixin[WeatherServiceGen, WeatherServiceOperation] { diff --git a/modules/codegen/src/smithy4s/codegen/internals/IR.scala b/modules/codegen/src/smithy4s/codegen/internals/IR.scala index fbdc20cdc..3519c1d3a 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/IR.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/IR.scala @@ -31,6 +31,7 @@ import TypedNode.FieldTN.OptionalSomeTN import TypedNode.FieldTN.RequiredTN import TypedNode.AltValueTN.ProductAltTN import TypedNode.AltValueTN.TypeAltTN +import TypedNode.AltValueTN.UnitAltTN import UnionMember._ import LineSegment.{NameDef, NameRef} @@ -426,6 +427,7 @@ private[internals] object TypedNode { def map[B](f: A => B): AltValueTN[B] = this match { case ProductAltTN(value) => ProductAltTN(f(value)) case TypeAltTN(value) => TypeAltTN(f(value)) + case UnitAltTN => UnitAltTN } } object AltValueTN { @@ -437,6 +439,7 @@ private[internals] object TypedNode { fa match { case ProductAltTN(value) => f(value).map(ProductAltTN(_)) case TypeAltTN(value) => f(value).map(TypeAltTN(_)) + case UnitAltTN => Applicative[G].pure(UnitAltTN) } def foldLeft[A, B](fa: AltValueTN[A], b: B)(f: (B, A) => B): B = ??? def foldRight[A, B](fa: AltValueTN[A], lb: Eval[B])( @@ -446,6 +449,7 @@ private[internals] object TypedNode { case class ProductAltTN[A](value: A) extends AltValueTN[A] case class TypeAltTN[A](value: A) extends AltValueTN[A] + case object UnitAltTN extends AltValueTN[Nothing] } implicit val typedNodeTraverse: Traverse[TypedNode] = diff --git a/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala b/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala index 1adccaf79..ae4de8862 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala @@ -355,7 +355,7 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => ) }, newline, - line"def $transform_: $Transformation.PartiallyApplied[$genName[F]] = $Transformation.of[$genName[F]](this)" + line"final def $transform_: $Transformation.PartiallyApplied[$genName[F]] = $Transformation.of[$genName[F]](this)" ), newline, lines( @@ -1613,6 +1613,9 @@ private[internals] class Renderer(compilationUnit: CompilationUnit) { self => case AltTN(ref, altName, AltValueTN.TypeAltTN(alt)) => line"${ref.show}.${altName.capitalize}Case(${alt.runDefault}).widen".write + case AltTN(ref, altName, AltValueTN.UnitAltTN) => + line"${ref.show}.${altName.capitalize}Case.widen".write + case AltTN(_, _, AltValueTN.ProductAltTN(alt)) => alt.runDefault.write diff --git a/modules/codegen/src/smithy4s/codegen/internals/SmithyToIR.scala b/modules/codegen/src/smithy4s/codegen/internals/SmithyToIR.scala index bee39fb2e..0ccc14bd2 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/SmithyToIR.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/SmithyToIR.scala @@ -1048,7 +1048,9 @@ private[codegen] class SmithyToIR( maybeTypeclassesHint(shape) } - case class AltInfo(name: String, tpe: Type, isAdtMember: Boolean) + case class AltInfo(name: String, tpe: Type, isAdtMember: Boolean) { + def isUnit: Boolean = tpe == Type.unit + } implicit class ShapeExt(shape: Shape) { def name = shape.getId().getName() @@ -1151,21 +1153,17 @@ private[codegen] class SmithyToIR( shape .members() .asScala - .map { member => - val memberTarget = - model.expectShape(member.getTarget) - if (isPartOfAdt(memberTarget)) { - (member.getMemberName(), member.tpe.map(Left(_))) - } else { - (member.getMemberName(), member.tpe.map(Right(_))) + .flatMap { member => + member.tpe.map { tpe => + val memberTarget = model.expectShape(member.getTarget) + + AltInfo( + member.getMemberName(), + tpe, + isAdtMember = isPartOfAdt(memberTarget) + ) } } - .collect { - case (name, Some(Left(tpe))) => - AltInfo(name, tpe, isAdtMember = true) - case (name, Some(Right(tpe))) => - AltInfo(name, tpe, isAdtMember = false) - } .toList } @@ -1302,6 +1300,8 @@ private[codegen] class SmithyToIR( val a = if (alt.isAdtMember) { val t = NodeAndType(node, alt.tpe) TypedNode.AltValueTN.ProductAltTN(t) + } else if (alt.isUnit) { + TypedNode.AltValueTN.UnitAltTN } else { val t = NodeAndType(node, alt.tpe) TypedNode.AltValueTN.TypeAltTN(t) diff --git a/sampleSpecs/misc.smithy b/sampleSpecs/misc.smithy index 27f8f3f9d..a5392c2a8 100644 --- a/sampleSpecs/misc.smithy +++ b/sampleSpecs/misc.smithy @@ -110,3 +110,14 @@ structure RangeCheck { // face with sunglasses emoji @pattern("^\\uD83D\\uDE0E$") string UnicodeRegexString + +@trait +union unionTraitWithUnitCase { + u: Unit + s: String +} + +@unionTraitWithUnitCase(u: { + +}) +string HasUnionUnitCaseTrait