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 9package main 10 11type S struct { a int } 12type T struct { b string } 13 14func (s *S) Name() int8 { return 1 } 15func (t *T) Name() int64 { return 64 } 16 17type I1 interface { Name() int8 } 18type I2 interface { Name() int64 } 19 20func main() { 21 shouldPanic(p1) 22} 23 24func p1() { 25 var i1 I1 26 var s *S 27 i1 = s 28 print(i1.(I2).Name()) 29} 30 31func shouldPanic(f func()) { 32 defer func() { 33 if recover() == nil { 34 panic("function should panic") 35 } 36 }() 37 f() 38} 39