@@ -1674,6 +1674,14 @@ func (g *generator) declareFunction(owner wit.TypeOwner, dir wit.Direction, f *w
1674
1674
return fdecl , nil
1675
1675
}
1676
1676
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
+
1677
1685
if dir == wit .Imported {
1678
1686
g .ensureParamImports (file , tdir , f .Params )
1679
1687
g .ensureParamImports (file , tdir , f .Results )
@@ -1777,14 +1785,6 @@ func (g *generator) defineImportedFunction(decl *funcDecl) error {
1777
1785
1778
1786
file := decl .goFunc .file
1779
1787
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
-
1788
1788
// Bridging between Go and wasm function
1789
1789
callParams := slices .Clone (decl .wasmFunc .params )
1790
1790
for i := range callParams {
@@ -1965,14 +1965,6 @@ func (g *generator) defineExportedFunction(decl *funcDecl) error {
1965
1965
file := decl .goFunc .file
1966
1966
scope := g .exportScopes [decl .owner ]
1967
1967
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
-
1976
1968
// Bridging between wasm and Go function
1977
1969
callParams := slices .Clone (decl .goFunc .params )
1978
1970
for i := range callParams {
0 commit comments