Source file test/typeparam/issue54135.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  type Foo struct{}
    10  
    11  func (Foo) Blanker() {}
    12  
    13  type Bar[T any] interface {
    14  	Blanker()
    15  }
    16  
    17  type Baz interface {
    18  	Some()
    19  }
    20  
    21  func check[T comparable](p Bar[T]) {
    22  	if x, ok := p.(any); !ok || x != p {
    23  		panic("FAIL")
    24  	}
    25  	if _, ok := p.(Baz); ok {
    26  		panic("FAIL")
    27  	}
    28  }
    29  
    30  func main() {
    31  	check[int](Foo{})
    32  }
    33  

View as plain text