1
0
mirror of https://github.com/golang/go synced 2024-11-21 19:14:44 -07:00

test: Add test for inheriting private method from anonymous field.

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
This commit is contained in:
Ian Lance Taylor 2011-09-14 10:31:51 -07:00
parent 1007a11924
commit 5f172fadbe
4 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,12 @@
package main
import (
"./p"
)
type T struct{ *p.S }
func main() {
var t T
p.F(t)
}

16
test/bugs/bug367.dir/p.go Normal file
View File

@ -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()
}

7
test/bugs/bug367.go Normal file
View File

@ -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

View File

@ -155,3 +155,7 @@ panic: interface conversion: interface is main.T, not main.T
0x0 0x0
== bugs/ == bugs/
=========== bugs/bug367.go
panic: interface conversion: main.T is not p.I: missing method get
BUG: should not fail