]> Cypherpunks repositories - gostls13.git/commitdiff
test: Add test for inheriting private method from anonymous field.
authorIan Lance Taylor <iant@golang.org>
Wed, 14 Sep 2011 17:31:51 +0000 (10:31 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 14 Sep 2011 17:31:51 +0000 (10:31 -0700)
The spec says that all methods are inherited from an anonymous
field.  There is no exception for non-exported methods.

This is related to issue 1536.

R=rsc
CC=golang-dev
https://golang.org/cl/5012043

test/bugs/bug367.dir/main.go [new file with mode: 0644]
test/bugs/bug367.dir/p.go [new file with mode: 0644]
test/bugs/bug367.go [new file with mode: 0644]
test/golden.out

diff --git a/test/bugs/bug367.dir/main.go b/test/bugs/bug367.dir/main.go
new file mode 100644 (file)
index 0000000..ab5d170
--- /dev/null
@@ -0,0 +1,12 @@
+package main
+
+import (
+       "./p"
+)
+
+type T struct{ *p.S }
+
+func main() {
+       var t T
+       p.F(t)
+}
diff --git a/test/bugs/bug367.dir/p.go b/test/bugs/bug367.dir/p.go
new file mode 100644 (file)
index 0000000..4e27d4e
--- /dev/null
@@ -0,0 +1,16 @@
+package p
+
+type T struct{ x int }
+type S struct{}
+
+func (p *S) get() T {
+       return T{0}
+}
+
+type I interface {
+       get() T
+}
+
+func F(i I) {
+       _ = i.get()
+}
diff --git a/test/bugs/bug367.go b/test/bugs/bug367.go
new file mode 100644 (file)
index 0000000..073e3b1
--- /dev/null
@@ -0,0 +1,7 @@
+// $G $D/$F.dir/p.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: should not fail
+
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+ignored
index 1942f45fbe632fa95f8dd6d717c38dbcd4a15c2b..fc4b81d3bd30f548a0b4ab4a51555af1a77d6f2c 100644 (file)
@@ -155,3 +155,7 @@ panic: interface conversion: interface is main.T, not main.T
 0x0
 
 == bugs/
+
+=========== bugs/bug367.go
+panic: interface conversion: main.T is not p.I: missing method get
+BUG: should not fail