Skip to content

Commit ca608fc

Browse files
committed
wit/bindgen: predeclare MarshalText and UnmarshalText methods
1 parent f42f71a commit ca608fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

wit/bindgen/generator.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,9 @@ func (g *generator) declareTypeDef(file *gen.File, dir wit.Direction, t *wit.Typ
574574
// Predeclare reserved methods.
575575
switch t.Kind.(type) {
576576
case *wit.Enum:
577-
decl.scope.DeclareName("String") // For fmt.Stringer
577+
decl.scope.DeclareName("String") // For fmt.Stringer
578+
decl.scope.DeclareName("MarshalText") // For encoding.TextMarshaler
579+
decl.scope.DeclareName("UnmarshalText") // For encoding.TextUnmarshaler
578580
case *wit.Variant:
579581
decl.scope.DeclareName("Tag") // Method on cm.Variant
580582
decl.scope.DeclareName("String") // For fmt.Stringer

0 commit comments

Comments
 (0)