Source file test/fixedbugs/bug201.go

     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  package main
     8  
     9  type T1 struct {
    10  	x, y int
    11  }
    12  type T2 struct {
    13  	z, w byte
    14  }
    15  type T3 T1
    16  
    17  type MyInt int
    18  
    19  func (MyInt) m(*T1) {}
    20  
    21  func 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  

View as plain text