2008-11-05 13:06:48 -07:00
|
|
|
// errchk $G $D/$F.go
|
|
|
|
|
|
|
|
// Copyright 2009 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.
|
|
|
|
|
|
|
|
package main
|
2009-01-20 15:40:40 -07:00
|
|
|
type S struct { a int }
|
|
|
|
type PS *S
|
2008-11-05 13:06:48 -07:00
|
|
|
func (p *S) get() int {
|
|
|
|
return p.a
|
|
|
|
}
|
2009-05-05 14:41:46 -06:00
|
|
|
|
2008-11-05 13:06:48 -07:00
|
|
|
func fn(p PS) int {
|
2009-05-05 14:41:46 -06:00
|
|
|
// p has type PS, and PS has no methods.
|
|
|
|
// (a compiler might see that p is a pointer
|
|
|
|
// and go looking in S without noticing PS.)
|
2009-05-19 16:23:43 -06:00
|
|
|
return p.get() // ERROR "undefined"
|
2008-11-05 13:06:48 -07:00
|
|
|
}
|
|
|
|
func main() {
|
2009-03-03 09:39:12 -07:00
|
|
|
s := S{1};
|
2008-11-05 13:06:48 -07:00
|
|
|
if s.get() != 1 {
|
|
|
|
panic()
|
|
|
|
}
|
|
|
|
}
|