Source file test/typeparam/issue51700.go

     1  // run
     2  
     3  // Copyright 2022 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  func f[B any](b B) {
    10  	if b1, ok := any(b).(interface{ m1() }); ok {
    11  		panic(1)
    12  		_ = b1.(B)
    13  	}
    14  	if b2, ok := any(b).(interface{ m2() }); ok {
    15  		panic(2)
    16  		_ = b2.(B)
    17  	}
    18  }
    19  
    20  type S struct{}
    21  
    22  func (S) m3() {}
    23  
    24  func main() {
    25  	f(S{})
    26  }
    27  

View as plain text