Makes wazero.CompiledCode an interface instead of a struct (#519)

This makes wazero.CompiledCode an interface instead of a struct to
prevent it from being used incorrectly. For example, even though the
fields are not exported, someone can mistakenly instantiate this
when it is a struct, and in doing so violate internal assumptions.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-05-02 11:44:01 +08:00
committed by GitHub
parent a91140f7f7
commit fbea2de984
8 changed files with 61 additions and 36 deletions

View File

@@ -344,8 +344,9 @@ func TestNewModuleBuilder_Build(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
b := tc.input(NewRuntime()).(*moduleBuilder)
m, err := b.Build(testCtx)
compiled, err := b.Build(testCtx)
require.NoError(t, err)
m := compiled.(*compiledCode)
requireHostModuleEquals(t, tc.expected, m.module)