Skip to content

Commit 76ef08d

Browse files
committed
wit/bindgen: use cm.Case directly instead of calling a case method on generated variant
1 parent dd65f16 commit 76ef08d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

wit/bindgen/generator.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ func (g *generator) lowerFlags(file *gen.File, dir wit.Direction, t *wit.TypeDef
11241124
}
11251125

11261126
func (g *generator) lowerVariant(file *gen.File, dir wit.Direction, t *wit.TypeDef, input string) string {
1127-
decl, _ := g.typeDecl(dir, t)
1127+
// decl, _ := g.typeDecl(dir, t)
11281128
v := t.Kind.(*wit.Variant)
11291129
flat := t.Flat()
11301130
if v.Enum() != nil {
@@ -1139,9 +1139,10 @@ func (g *generator) lowerVariant(file *gen.File, dir wit.Direction, t *wit.TypeD
11391139
continue
11401140
}
11411141
caseNum := strconv.Itoa(i)
1142-
caseName := decl.scope.GetName(GoName(c.Name, true))
1142+
// caseName := decl.scope.GetName(GoName(c.Name, true))
1143+
input := "*" + g.cmCall(abiFile, "Case["+g.typeRep(file, dir, c.Type)+"]", "&v, "+caseNum)
11431144
stringio.Write(&b, "case ", caseNum, ": // ", c.Name, "\n")
1144-
b.WriteString(g.lowerVariantCaseInto(abiFile, dir, c.Type, flat[1:], "*v."+caseName+"()"))
1145+
b.WriteString(g.lowerVariantCaseInto(abiFile, dir, c.Type, flat[1:], input))
11451146
}
11461147
b.WriteString("}\n")
11471148
b.WriteString("return\n")

0 commit comments

Comments
 (0)