Source file test/typeparam/issue48838.go

     1  // run
     2  
     3  // Copyright 2021 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 main() {
    10  	check[string]()
    11  }
    12  
    13  func check[T any]() {
    14  	var result setter[T]
    15  	switch result.(type) {
    16  	case fooA[T]:
    17  	case fooB[T]:
    18  	}
    19  }
    20  
    21  type setter[T any] interface {
    22  	Set(T)
    23  }
    24  
    25  type fooA[T any] struct{}
    26  
    27  func (fooA[T]) Set(T) {}
    28  
    29  type fooB[T any] struct{}
    30  
    31  func (fooB[T]) Set(T) {}
    32  

View as plain text