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:
@@ -853,12 +853,12 @@ func TestCompiledCode_Close(t *testing.T) {
|
||||
for _, ctx := range []context.Context{nil, testCtx} { // Ensure it doesn't crash on nil!
|
||||
e := &mockEngine{name: "1", cachedModules: map[*wasm.Module]struct{}{}}
|
||||
|
||||
var cs []*CompiledCode
|
||||
var cs []*compiledCode
|
||||
for i := 0; i < 10; i++ {
|
||||
m := &wasm.Module{}
|
||||
err := e.CompileModule(ctx, m)
|
||||
require.NoError(t, err)
|
||||
cs = append(cs, &CompiledCode{module: m, compiledEngine: e})
|
||||
cs = append(cs, &compiledCode{module: m, compiledEngine: e})
|
||||
}
|
||||
|
||||
// Before Close.
|
||||
|
||||
Reference in New Issue
Block a user