2008-11-05 23:06:48 +03: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
|
2010-03-30 21:34:57 +04:00
|
|
|
|
|
|
|
type S struct {
|
|
|
|
a int
|
|
|
|
}
|
2009-01-21 01:40:40 +03:00
|
|
|
type PS *S
|
2010-03-30 21:34:57 +04:00
|
|
|
|
2008-11-05 23:06:48 +03:00
|
|
|
func (p *S) get() int {
|
2009-08-18 00:30:22 +04:00
|
|
|
return p.a
|
2008-11-05 23:06:48 +03:00
|
|
|
}
|
2009-05-06 00:41:46 +04:00
|
|
|
|
2008-11-05 23:06:48 +03:00
|
|
|
func fn(p PS) int {
|
2009-08-18 00:30:22 +04: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 21:34:57 +04:00
|
|
|
return p.get() // ERROR "undefined"
|
2008-11-05 23:06:48 +03:00
|
|
|
}
|
|
|
|
func main() {
|
2010-03-30 21:34:57 +04:00
|
|
|
s := S{1}
|
2009-08-18 00:30:22 +04:00
|
|
|
if s.get() != 1 {
|
2010-03-30 21:34:57 +04:00
|
|
|
panic("fail")
|
2009-08-18 00:30:22 +04:00
|
|
|
}
|
2008-11-05 23:06:48 +03:00
|
|
|
}
|