2012-02-16 21:50:37 -07:00
|
|
|
// errorcheck
|
2009-05-21 14:46:20 -06:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
2009-05-06 18:05:55 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2009-05-12 17:09:47 -06:00
|
|
|
// Error messages about missing implicit methods.
|
|
|
|
|
2009-05-06 18:05:55 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
type T int
|
2010-06-08 19:50:02 -06:00
|
|
|
|
2009-05-06 18:05:55 -06:00
|
|
|
func (t T) V()
|
|
|
|
func (t *T) P()
|
|
|
|
|
2010-06-08 19:50:02 -06:00
|
|
|
type V interface {
|
|
|
|
V()
|
|
|
|
}
|
|
|
|
type P interface {
|
|
|
|
P()
|
|
|
|
V()
|
|
|
|
}
|
2009-05-06 18:05:55 -06:00
|
|
|
|
2010-06-08 19:50:02 -06:00
|
|
|
type S struct {
|
|
|
|
T
|
|
|
|
}
|
|
|
|
type SP struct {
|
|
|
|
*T
|
|
|
|
}
|
2009-05-06 18:05:55 -06:00
|
|
|
|
|
|
|
func main() {
|
2010-06-08 19:50:02 -06:00
|
|
|
var t T
|
|
|
|
var v V
|
|
|
|
var p P
|
|
|
|
var s S
|
|
|
|
var sp SP
|
|
|
|
|
|
|
|
v = t
|
|
|
|
p = t // ERROR "does not implement|requires a pointer"
|
|
|
|
_, _ = v, p
|
|
|
|
v = &t
|
|
|
|
p = &t
|
|
|
|
_, _ = v, p
|
|
|
|
|
|
|
|
v = s
|
|
|
|
p = s // ERROR "does not implement|requires a pointer"
|
|
|
|
_, _ = v, p
|
|
|
|
v = &s
|
|
|
|
p = &s
|
|
|
|
_, _ = v, p
|
|
|
|
|
|
|
|
v = sp
|
|
|
|
p = sp // no error!
|
|
|
|
_, _ = v, p
|
|
|
|
v = &sp
|
|
|
|
p = &sp
|
|
|
|
_, _ = v, p
|
2009-05-06 18:05:55 -06:00
|
|
|
}
|