github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/types/testdata/fixedbugs/issue50816.go (about)

     1  // Copyright 2022 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package pkg
     6  
     7  type I interface {
     8  	Foo()
     9  }
    10  
    11  type T1 struct{}
    12  
    13  func (T1) foo() {}
    14  
    15  type T2 struct{}
    16  
    17  func (T2) foo() string { return "" }
    18  
    19  func _() {
    20  	var i I
    21  	_ = i /* ERROR "impossible type assertion: i.(T1)\n\tT1 does not implement I (missing method Foo)\n\t\thave foo()\n\t\twant Foo()" */ .(T1)
    22  	_ = i /* ERROR "impossible type assertion: i.(T2)\n\tT2 does not implement I (missing method Foo)\n\t\thave foo() string\n\t\twant Foo()" */ .(T2)
    23  }