smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

Ad Hoc Extension of Service Default Implementation

Open bpholt opened this issue 2 years ago • 0 comments

When using …Gen.Default(…) { … some overrides … } on Scala 3, I get a warning like

[warn]    |Unless class Constant is declared 'open', its extension in a separate file should be enabled
[warn]    |by adding the import clause 'import scala.language.adhocExtensions'
[warn]    |or by setting the compiler option -language:adhocExtensions.
[warn]    |See the Scala docs for value scala.language.adhocExtensions for a discussion
[warn]    |why the feature should be explicitly enabled.

This is what my instance looks like:

new AutoScaling.Default[IO](new NotImplementedError().raiseError) {
  override def completeLifecycleAction(lifecycleHookName: AsciiStringMaxLen255,
                                       autoScalingGroupName: ResourceName,
                                       lifecycleActionResult: LifecycleActionResult,
                                       lifecycleActionToken: Option[LifecycleActionToken],
                                       instanceId: Option[XmlStringMaxLen19]): IO[CompleteLifecycleActionAnswer] =
    deferredCompleteLifecycleActionRequest.complete((lifecycleHookName, autoScalingGroupName, lifecycleActionResult, instanceId))
      .as(CompleteLifecycleActionAnswer())
}

It feels like Default is meant to be partially overridden like this, meaning it should ideally be enabled at the source, either by adding open or abstract to the class definition.

bpholt avatar Nov 22 '23 06:11 bpholt