github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/test/interface/returntype.go (about) 1 // run 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 // Test interface methods with different return types are distinct. 8 9 package main 10 11 type S struct { a int } 12 type T struct { b string } 13 14 func (s *S) Name() int8 { return 1 } 15 func (t *T) Name() int64 { return 64 } 16 17 type I1 interface { Name() int8 } 18 type I2 interface { Name() int64 } 19 20 func main() { 21 shouldPanic(p1) 22 } 23 24 func p1() { 25 var i1 I1 26 var s *S 27 i1 = s 28 print(i1.(I2).Name()) 29 } 30 31 func shouldPanic(f func()) { 32 defer func() { 33 if recover() == nil { 34 panic("function should panic") 35 } 36 }() 37 f() 38 }