diff --git a/CHANGELOG.md b/CHANGELOG.md index 3367df999..b7fd004e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.18.8 + +* Fix collision avoidance algorithm to cover Scala 3 keywords + # 0.18.7 * Added support for `@httpResponseCode` on newtypes (integer shapes that aren't exactly `smithy.api#Integer`), as well as refinements (e.g. ints with a `@range` constraint). diff --git a/modules/bootstrapped/src/generated/smithy4s/example/collision/Scala3ReservedKeywords.scala b/modules/bootstrapped/src/generated/smithy4s/example/collision/Scala3ReservedKeywords.scala new file mode 100644 index 000000000..e0846e10b --- /dev/null +++ b/modules/bootstrapped/src/generated/smithy4s/example/collision/Scala3ReservedKeywords.scala @@ -0,0 +1,22 @@ +package smithy4s.example.collision + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.Schema.struct + +final case class Scala3ReservedKeywords(_export: Option[String] = None, _enum: Option[String] = None) + +object Scala3ReservedKeywords extends ShapeTag.Companion[Scala3ReservedKeywords] { + val id: ShapeId = ShapeId("smithy4s.example.collision", "Scala3ReservedKeywords") + + val hints: Hints = Hints.empty + + implicit val schema: Schema[Scala3ReservedKeywords] = struct( + String.schema.optional[Scala3ReservedKeywords]("export", _._export), + String.schema.optional[Scala3ReservedKeywords]("enum", _._enum), + ){ + Scala3ReservedKeywords.apply + }.withId(id).addHints(hints) +} diff --git a/modules/codegen/src/smithy4s/codegen/internals/CollisionAvoidance.scala b/modules/codegen/src/smithy4s/codegen/internals/CollisionAvoidance.scala index 252926833..f3632b204 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/CollisionAvoidance.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/CollisionAvoidance.scala @@ -279,7 +279,14 @@ private[internals] object CollisionAvoidance { "notify", "notifyAll", "toString", - "wait" + "wait", + + // scala 3 "regular" keywords + // https://docs.scala-lang.org/scala3/guides/migration/incompat-syntactic.html#restricted-keywords + "enum", + "export", + "given", + "then" ) class Names() { diff --git a/sampleSpecs/reservednames.smithy b/sampleSpecs/reservednames.smithy index ed2043b23..9991f479d 100644 --- a/sampleSpecs/reservednames.smithy +++ b/sampleSpecs/reservednames.smithy @@ -141,3 +141,8 @@ enum KeywordEnum { implicit package = "class" } + +structure Scala3ReservedKeywords { + export: String + enum: String +}