1// errorcheck 2 3// Copyright 2009 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7// Verify compiler complains about missing implicit methods. 8// Does not compile. 9 10package main 11 12type T int 13 14func (t T) V() 15func (t *T) P() 16 17type V interface { 18 V() 19} 20type P interface { 21 P() 22 V() 23} 24 25type S struct { 26 T 27} 28type SP struct { 29 *T 30} 31 32func main() { 33 var t T 34 var v V 35 var p P 36 var s S 37 var sp SP 38 39 v = t 40 p = t // ERROR "does not implement|requires a pointer|cannot use" 41 _, _ = v, p 42 v = &t 43 p = &t 44 _, _ = v, p 45 46 v = s 47 p = s // ERROR "does not implement|requires a pointer|cannot use" 48 _, _ = v, p 49 v = &s 50 p = &s 51 _, _ = v, p 52 53 v = sp 54 p = sp // no error! 55 _, _ = v, p 56 v = &sp 57 p = &sp 58 _, _ = v, p 59} 60