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 7package main 8 9type T1 struct { 10 x, y int 11} 12type T2 struct { 13 z, w byte 14} 15type T3 T1 16 17type MyInt int 18 19func (MyInt) m(*T1) {} 20 21func main() { 22 { 23 var i interface{} = new(T1) 24 _, ok1 := i.(*T1) 25 _, ok2 := i.(*T2) 26 _, ok3 := i.(*T3) 27 if !ok1 || ok2 || ok3 { 28 println("*T1", ok1, ok2, ok3) 29 panic("fail") 30 } 31 } 32 { 33 var i interface{} = MyInt(0) 34 _, ok1 := i.(interface { 35 m(*T1) 36 }) 37 _, ok2 := i.(interface { 38 m(*T2) 39 }) 40 _, ok3 := i.(interface { 41 m(*T3) 42 }) 43 if !ok1 || ok2 || ok3 { 44 println("T", ok1, ok2, ok3) 45 panic("fail") 46 } 47 } 48} 49