// I don't see a good way to remedy this shy of making more granular (unexported!) methods. (Might be worth it.)
// This probably also isn't the same for all of the assembler methods: the methods we delegate to aren't doing as many check branches when they're for scalars,
// because they expected to be used in contexts where many values of the 'm' enum aren't reachable -- an expectation we've suddenly subverted with this path!
//
// FUTURE: The error returns here are deeply questionable, and not as helpful as they could be.
// ErrNotUnionStructure is about the most applicable thing so far, but it's very freetext.
// ErrWrongKind wouldn't fit at all: assumes that we can say what kind of node we have, but this is the one case in the whole system where *we can't*; also, assumes there's one actual correct kind, and that too is false here!
maybeNilComma:=""
iftwoReturns{
maybeNilComma+="nil,"
}
return`
func (na *_{{ .Type | TypeSymbol }}__ReprAssembler) `+methodSig+` {
// TODO i think you finally Need a method for if-no-members-match-this-kind for the default rejection to compile this time.
return nil, ipld.ErrWrongKind{doozy}
return `+maybeNilComma+` schema.ErrNotUnionStructure{TypeName: "{{ .PkgName }}.{{ .Type.Name }}.Repr", Detail: "`+methodName+` called but is not valid for any of the kinds that are valid members of this union"}
// TODO: I think this may need some special handling to account for if our union is itself used in a nullable circumstance; that should overrule this behavior.