From 07ec5bdd6dfc591e4b96a2652e9b9fcc306f054d Mon Sep 17 00:00:00 2001 From: David Francoeur Date: Mon, 18 Dec 2023 22:36:49 -0500 Subject: [PATCH] TO REMOVE ??? --- .mill-version | 2 +- buildSetup.sc | 7 ++- .../src/internals/IModelToSmithy.scala | 43 +++++++++---------- .../postprocess/AllOfTransformer.scala | 1 - 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.mill-version b/.mill-version index af88ba8..e5cbde3 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.11.1 +0.11.6 diff --git a/buildSetup.sc b/buildSetup.sc index 399b63c..b808b47 100644 --- a/buildSetup.sc +++ b/buildSetup.sc @@ -174,9 +174,8 @@ case class ScalacOption( // format: off private val allScalacOptions = Seq( - ScalacOption("-Xsource:3", isSupported = version => v211 <= version || version < v300), // Treat compiler input as Scala source for the specified version, see scala/bug#8126. - ScalacOption("-deprecation", isSupported = version => version < v213 || v300 <= version), // Emit warning and location for usages of deprecated APIs. Not really removed but deprecated in 2.13. - ScalacOption("-migration", isSupported = v300 <= _), // Emit warning and location for migration issues from Scala 2. + ScalacOption("-Xsource:3", isSupported = version => v211 <= version && version < v300), // Treat compiler input as Scala source for the specified version, see scala/bug#8126. + ScalacOption("-deprecation", isSupported = version => version < v213 && v300 <= version), // Emit warning and location for usages of deprecated APIs. Not really removed but deprecated in 2.13. ScalacOption("-explaintypes", isSupported = _ < v300), // Explain type errors in more detail. ScalacOption("-explain-types", isSupported = v300 <= _), // Explain type errors in more detail. ScalacOption("-explain", isSupported = v300 <= _), // Explain errors in more detail. @@ -188,7 +187,7 @@ private val allScalacOptions = Seq( ScalacOption("-language:existentials,experimental.macros,higherKinds,implicitConversions", isSupported = v300 <= _), // the four options above, dotty style ScalacOption("-unchecked"), // Enable additional warnings where generated code depends on assumptions. ScalacOption("-Xcheckinit", isSupported = _ < v300), // Wrap field accessors to throw an exception on uninitialized access. - ScalacOption("-Xfatal-warnings"), // Fail the compilation if there are any warnings. + ScalacOption("-Xfatal-warnings", isSupported = _ < v300), // Fail the compilation if there are any warnings. ScalacOption("-Xlint", isSupported = _ < v211), // Used to mean enable all linting options but now the syntax for that is different (-Xlint:_ I think) ScalacOption("-Xlint:adapted-args", isSupported = version => v211 <= version && version < v300), // Warn if an argument list is modified to match the receiver. ScalacOption("-Xlint:by-name-right-associative", isSupported = version => v211 <= version && version < v213), // By-name parameter of right associative operator. diff --git a/modules/compiler-core/src/internals/IModelToSmithy.scala b/modules/compiler-core/src/internals/IModelToSmithy.scala index 703af1a..8b71c62 100644 --- a/modules/compiler-core/src/internals/IModelToSmithy.scala +++ b/modules/compiler-core/src/internals/IModelToSmithy.scala @@ -45,7 +45,7 @@ private[compiler] final class IModelToSmithy(useEnumTraitSyntax: Boolean) extends (IModel => Model) { def apply(iModel: IModel): Model = { - val shapes = iModel.definitions.map { + val shapes: Vector[JShape] = iModel.definitions.map { case Structure(id, fields, _, structHints) => val members = fields.map { case Field(id, tpe, hints) => val memName = id.memberName.value.toString @@ -130,27 +130,28 @@ private[compiler] final class IModelToSmithy(useEnumTraitSyntax: Boolean) } builder.build() case Newtype(id, target, hints) => - val builder = target.name.segments.last.value.toString match { - case "String" => StringShape.builder() - case "Integer" => IntegerShape.builder() - case "Long" => LongShape.builder() - case "BigInteger" => BigIntegerShape.builder() - case "BigDecimal" => BigDecimalShape.builder() - case "Short" => ShortShape.builder() - case "Float" => FloatShape.builder() - case "Double" => DoubleShape.builder() - case "Boolean" => BooleanShape.builder() - case "Byte" => ByteShape.builder() - case "Timestamp" => TimestampShape.builder() - case "Document" => DocumentShape.builder() - case "UUID" => StringShape.builder().addTrait(new UuidFormatTrait()) - case "Null" => - StructureShape.builder().addTrait(new NullFormatTrait()) - case other => sys.error(s"error processing $id, found $other") - } + val builder: AbstractShapeBuilder[_, _] = + target.name.segments.last.value.toString match { + case "String" => StringShape.builder() + case "Integer" => IntegerShape.builder() + case "Long" => LongShape.builder() + case "BigInteger" => BigIntegerShape.builder() + case "BigDecimal" => BigDecimalShape.builder() + case "Short" => ShortShape.builder() + case "Float" => FloatShape.builder() + case "Double" => DoubleShape.builder() + case "Boolean" => BooleanShape.builder() + case "Byte" => ByteShape.builder() + case "Timestamp" => TimestampShape.builder() + case "Document" => DocumentShape.builder() + case "UUID" => StringShape.builder().addTrait(new UuidFormatTrait()) + case "Null" => + StructureShape.builder().addTrait(new NullFormatTrait()) + case other => sys.error(s"error processing $id, found $other") + } builder.id(id.toSmithy) hintsToTraits(hints).foreach(builder.addTrait(_)) - builder.build() + builder.build().asInstanceOf[JShape] // WTF? case OperationDef(id, input, output, errors, hints) => val builder = OperationShape.builder().id(id.toSmithy) @@ -167,8 +168,6 @@ private[compiler] final class IModelToSmithy(useEnumTraitSyntax: Boolean) operations.foreach(o => builder.addOperation(o.toSmithy)) builder.build() case e: Enumeration => buildEnum(e) - case other => - throw new IllegalArgumentException(s"Unexpected input: $other") } val builder = Model.builder() if (iModel.suppressions.nonEmpty) { diff --git a/modules/compiler-core/src/internals/postprocess/AllOfTransformer.scala b/modules/compiler-core/src/internals/postprocess/AllOfTransformer.scala index 09d841f..e396492 100644 --- a/modules/compiler-core/src/internals/postprocess/AllOfTransformer.scala +++ b/modules/compiler-core/src/internals/postprocess/AllOfTransformer.scala @@ -63,7 +63,6 @@ private[compiler] object AllOfTransformer extends IModelPostProcessor { case _: ServiceDef => false } loop(tail, hasRef) - case _ :: tail => loop(tail, isReferenced) } loop(allShapes.toList)