1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 type Exported interface {
15 type Implementation struct{}
17 func (p *Implementation) private() {}
21 // nothing unusual here
23 x = new(Implementation)
24 x.private() // main.Implementation.private()
26 // same here - should be and is legal
30 // this assignment is correctly illegal:
31 // px.private undefined (cannot refer to unexported field or method private)
34 // this assignment is correctly illegal:
35 // *Implementation does not implement p.Exported (missing p.private method)
36 // px = new(Implementation)
38 // this assignment is correctly illegal:
39 // p.Exported does not implement Exported (missing private method)
42 // this assignment unexpectedly compiles and then executes
48 println("should not get this far")
50 // this is a legitimate call, but because of the previous assignment,
51 // it invokes the method private in p!
52 x.private() // p.Implementation.private()