@@ -1674,6 +1674,14 @@ func (g *generator) declareFunction(owner wit.TypeOwner, dir wit.Direction, f *w
16741674 return fdecl , nil
16751675 }
16761676
1677+ // Define anonymous types
1678+ for _ , p := range f .Params {
1679+ g .defineAnonymousType (file , tdir , p .Type )
1680+ }
1681+ for _ , p := range f .Results {
1682+ g .defineAnonymousType (file , tdir , p .Type )
1683+ }
1684+
16771685 if dir == wit .Imported {
16781686 g .ensureParamImports (file , tdir , f .Params )
16791687 g .ensureParamImports (file , tdir , f .Results )
@@ -1777,14 +1785,6 @@ func (g *generator) defineImportedFunction(decl *funcDecl) error {
17771785
17781786 file := decl .goFunc .file
17791787
1780- // Define anonymous types
1781- for _ , p := range decl .goFunc .params {
1782- g .defineAnonymousType (file , p .dir , p .typ )
1783- }
1784- for _ , p := range decl .goFunc .results {
1785- g .defineAnonymousType (file , p .dir , p .typ )
1786- }
1787-
17881788 // Bridging between Go and wasm function
17891789 callParams := slices .Clone (decl .wasmFunc .params )
17901790 for i := range callParams {
@@ -1965,14 +1965,6 @@ func (g *generator) defineExportedFunction(decl *funcDecl) error {
19651965 file := decl .goFunc .file
19661966 scope := g .exportScopes [decl .owner ]
19671967
1968- // Define anonymous types
1969- for _ , p := range decl .goFunc .params {
1970- g .defineAnonymousType (file , p .dir , p .typ )
1971- }
1972- for _ , p := range decl .goFunc .results {
1973- g .defineAnonymousType (file , p .dir , p .typ )
1974- }
1975-
19761968 // Bridging between wasm and Go function
19771969 callParams := slices .Clone (decl .goFunc .params )
19781970 for i := range callParams {
0 commit comments