diff --git a/jit/jit_test.go b/jit/jit_test.go index df3cb455..aeb9b80c 100644 --- a/jit/jit_test.go +++ b/jit/jit_test.go @@ -1681,6 +1681,29 @@ func TestTypeMismatch(t *testing.T) { } +func TestIssue96(t *testing.T) { + conf := baseConfig + + data := testData{ + files: []string{"./testdata/test_issue96/test.go"}, + pkg: "./testdata/test_issue96", + } + testNames := []string{"BuildGoFiles", "BuildGoPackage", "BuildGoText"} + for _, testName := range testNames { + t.Run(testName, func(t *testing.T) { + module, symbols := buildLoadable(t, conf, testName, data) + + testFunc := symbols["NewStructX"] + results := reflect.ValueOf(testFunc).Call(nil) + fmt.Println(results[0].Interface().(interface{ Do() error }).Do()) + err := module.Unload() + if err != nil { + t.Fatal(err) + } + }) + } +} + func TestRemotePkgs(t *testing.T) { // This test tries to build some massive real world packages as a smoke test. // Ideally in future we'd also build and run the tests for those packages as JIT modules to prove everything works diff --git a/jit/testdata/test_issue96/test.go b/jit/testdata/test_issue96/test.go new file mode 100644 index 00000000..9bdb0370 --- /dev/null +++ b/jit/testdata/test_issue96/test.go @@ -0,0 +1,19 @@ +package test_issue96 + +import "fmt" + +type ( + IDo interface { + Do() error + } + Struct1 struct{} +) + +func (Struct1) Do() error { + fmt.Print("DO SOMETHING\n") + return nil +} + +func NewStructX() IDo { + return Struct1{} +}