You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reproduced in a scala REPL, but the same should happen in a regular java project with a dependency on smithy-model 1.22.0:
scala> :paste
// Entering paste mode (ctrl-D to finish)
import software.amazon.smithy.model.shapes.MemberShape
import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.traits.ErrorTrait
val structMember = MemberShape
.builder()
.id("test#struct$testing")
.target("smithy.api#Integer")
.build()
val struct =
StructureShape
.builder()
.id("test#struct")
.addMember(structMember)
.addTrait(new ErrorTrait("client"))
.build()
// Exiting paste mode, now interpreting.
java.lang.IllegalAccessError: failed to access class software.amazon.smithy.model.shapes.NamedMembersShape$Builder from class $iw (software.amazon.smithy.model.shapes.NamedMembersShape$Builder is in unnamed module of loader sbt.internal.inc.classpath.ClasspathUtil$$anon$2 @2dacc87b; $iw is in unnamed module of loader scala.tools.nsc.interpreter.IMain$TranslatingClassLoader @30001570)
... 67 elided
But if I do:
scala> :paste
// Entering paste mode (ctrl-D to finish)
import software.amazon.smithy.model.shapes.MemberShape
import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.traits.ErrorTrait
val structMember = MemberShape
.builder()
.id("test#struct$testing")
.target("smithy.api#Integer")
.build()
val struct =
StructureShape
.builder()
.id("test#struct")
.addTrait(new ErrorTrait("client"))
.addMember(structMember)
.build()
// Exiting paste mode, now interpreting.
import software.amazon.smithy.model.shapes.MemberShape
import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.traits.ErrorTrait
val structMember: software.amazon.smithy.model.shapes.MemberShape = (member: `test#struct$testing`)
val struct: software.amazon.smithy.model.shapes.StructureShape = (structure: `test#struct`)
It works fine. The only difference is the order of the calls in the builder. If I move .addTrait(new ErrorTrait("client")) after .addMember(structMember), it fails.
The text was updated successfully, but these errors were encountered:
I suppose we could flatten NamedMemberShape and NamedMemberShape.Builder into StructureShape and UnionShape. I'm not sure if that would work with Scala though.
Also hit this, for anyone seeing this before the upstream issue in Dotty is fixed, a workaround would be to explicitly upcast the return type of id / addMember to StructureShape.Builder.
For example (with a convenience extension method to avoid extra parentheses nesting:
Reproduced in a scala REPL, but the same should happen in a regular java project with a dependency on smithy-model 1.22.0:
But if I do:
It works fine. The only difference is the order of the calls in the builder. If I move
.addTrait(new ErrorTrait("client"))
after.addMember(structMember)
, it fails.The text was updated successfully, but these errors were encountered: