1// run 2 3// Copyright 2014 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 7package main 8 9import ( 10 "fmt" 11) 12 13type Foo int64 14 15func (f *Foo) F() int64 { 16 return int64(*f) 17} 18 19type Bar int64 20 21func (b Bar) F() int64 { 22 return int64(b) 23} 24 25type Baz int32 26 27func (b Baz) F() int64 { 28 return int64(b) 29} 30 31func main() { 32 foo := Foo(123) 33 f := foo.F 34 if foo.F() != f() { 35 bug() 36 fmt.Println("foo.F", foo.F(), f()) 37 } 38 bar := Bar(123) 39 f = bar.F 40 if bar.F() != f() { 41 bug() 42 fmt.Println("bar.F", bar.F(), f()) // duh! 43 } 44 45 baz := Baz(123) 46 f = baz.F 47 if baz.F() != f() { 48 bug() 49 fmt.Println("baz.F", baz.F(), f()) 50 } 51} 52 53var bugged bool 54 55func bug() { 56 if !bugged { 57 bugged = true 58 fmt.Println("BUG") 59 } 60} 61