Source file test/typeparam/issue46472.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 foo[T any](d T) {
    10  	switch v := interface{}(d).(type) {
    11  	case string:
    12  		if v != "x" {
    13  			panic("unexpected v: " + v)
    14  		}
    15  	}
    16  
    17  }
    18  func main() {
    19  	foo("x")
    20  }
    21  

View as plain text