diff --git a/crates/wit-parser/src/resolve/mod.rs b/crates/wit-parser/src/resolve/mod.rs index 8199afcfd7..12900fe4d0 100644 --- a/crates/wit-parser/src/resolve/mod.rs +++ b/crates/wit-parser/src/resolve/mod.rs @@ -2644,6 +2644,7 @@ package {name} is defined in two different locations:\n\ // above) and the `CloneMaps` are shared amongst interfaces. This // means that future clones will use the types produced here too. let mut new_id = id; + cloner.new_package = cloner.resolve.interfaces[new_id].package; cloner.interface(&mut new_id); // Load up the previous `key` and go ahead and mutate the diff --git a/tests/cli/nominal4.wit b/tests/cli/nominal4.wit new file mode 100644 index 0000000000..74fb39036d --- /dev/null +++ b/tests/cli/nominal4.wit @@ -0,0 +1,15 @@ +// RUN: component wit --generate-nominal-type-ids foo % --json + +package a:b; + +world foo { + import other:c/x; + export other:c/x; +} + +package other:c { + interface x { + resource r; + hi: func() -> r; + } +} diff --git a/tests/cli/nominal4.wit.stdout b/tests/cli/nominal4.wit.stdout new file mode 100644 index 0000000000..f2a0db18fd --- /dev/null +++ b/tests/cli/nominal4.wit.stdout @@ -0,0 +1,108 @@ +{ + "worlds": [ + { + "name": "foo", + "imports": { + "interface-0": { + "interface": { + "id": 0 + } + } + }, + "exports": { + "interface-1": { + "interface": { + "id": 1 + } + } + }, + "package": 1 + } + ], + "interfaces": [ + { + "name": "x", + "types": { + "r": 0 + }, + "functions": { + "hi": { + "name": "hi", + "kind": "freestanding", + "params": [], + "result": 1 + } + }, + "package": 0 + }, + { + "name": "x", + "types": { + "r": 2 + }, + "functions": { + "hi": { + "name": "hi", + "kind": "freestanding", + "params": [], + "result": 3 + } + }, + "package": 0, + "clone_of": 0 + } + ], + "types": [ + { + "name": "r", + "kind": "resource", + "owner": { + "interface": 0 + } + }, + { + "name": null, + "kind": { + "handle": { + "own": 0 + } + }, + "owner": null + }, + { + "name": "r", + "kind": "resource", + "owner": { + "interface": 1 + } + }, + { + "name": null, + "kind": { + "handle": { + "own": 2 + } + }, + "owner": null + } + ], + "packages": [ + { + "name": "other:c", + "interfaces": { + "x": 0 + }, + "worlds": {} + }, + { + "name": "a:b", + "docs": { + "contents": "RUN: component wit --generate-nominal-type-ids foo % --json" + }, + "interfaces": {}, + "worlds": { + "foo": 0 + } + } + ] +}