.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / go / ssa / interp / testdata / ifaceprom.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.1.1-0.20210319172145-bda8f5cee399/go/ssa/interp/testdata/ifaceprom.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.1.1-0.20210319172145-bda8f5cee399/go/ssa/interp/testdata/ifaceprom.go
new file mode 100644 (file)
index 0000000..414dc73
--- /dev/null
@@ -0,0 +1,58 @@
+package main
+
+// Test of promotion of methods of an interface embedded within a
+// struct.  In particular, this test exercises that the correct
+// method is called.
+
+type I interface {
+       one() int
+       two() string
+}
+
+type S struct {
+       I
+}
+
+type impl struct{}
+
+func (impl) one() int {
+       return 1
+}
+
+func (impl) two() string {
+       return "two"
+}
+
+func main() {
+       var s S
+       s.I = impl{}
+       if one := s.I.one(); one != 1 {
+               panic(one)
+       }
+       if one := s.one(); one != 1 {
+               panic(one)
+       }
+       closOne := s.I.one
+       if one := closOne(); one != 1 {
+               panic(one)
+       }
+       closOne = s.one
+       if one := closOne(); one != 1 {
+               panic(one)
+       }
+
+       if two := s.I.two(); two != "two" {
+               panic(two)
+       }
+       if two := s.two(); two != "two" {
+               panic(two)
+       }
+       closTwo := s.I.two
+       if two := closTwo(); two != "two" {
+               panic(two)
+       }
+       closTwo = s.two
+       if two := closTwo(); two != "two" {
+               panic(two)
+       }
+}