2012-02-16 21:49:30 -07:00
|
|
|
// errorcheck
|
2008-11-05 13:06:48 -07:00
|
|
|
|
|
|
|
// 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
|
2010-03-30 11:34:57 -06:00
|
|
|
|
|
|
|
type S struct {
|
|
|
|
a int
|
|
|
|
}
|
2009-01-20 15:40:40 -07:00
|
|
|
type PS *S
|
2010-03-30 11:34:57 -06:00
|
|
|
|
2008-11-05 13:06:48 -07:00
|
|
|
func (p *S) get() int {
|
2009-08-17 14:30:22 -06:00
|
|
|
return p.a
|
2008-11-05 13:06:48 -07:00
|
|
|
}
|
2009-05-05 14:41:46 -06:00
|
|
|
|
2008-11-05 13:06:48 -07:00
|
|
|
func fn(p PS) int {
|
2009-08-17 14:30:22 -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.)
|
2010-03-30 11:34:57 -06:00
|
|
|
return p.get() // ERROR "undefined"
|
2008-11-05 13:06:48 -07:00
|
|
|
}
|
|
|
|
func main() {
|
2010-03-30 11:34:57 -06:00
|
|
|
s := S{1}
|
2009-08-17 14:30:22 -06:00
|
|
|
if s.get() != 1 {
|
2010-03-30 11:34:57 -06:00
|
|
|
panic("fail")
|
2009-08-17 14:30:22 -06:00
|
|
|
}
|
2008-11-05 13:06:48 -07:00
|
|
|
}
|