Black Lives Matter. Support the Equal Justice Initiative.

Text file src/go/types/testdata/fixedbugs/issue42758.go2

Documentation: go/types/testdata/fixedbugs

     1  // Copyright 2020 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 p
     6  
     7  func _[T any](x interface{}){
     8  	switch x.(type) {
     9  	case T: // ok to use a type parameter
    10  	case int:
    11  	}
    12  
    13  	switch x.(type) {
    14  	case T:
    15  	case T /* ERROR duplicate case */ :
    16  	}
    17  }
    18  
    19  type constraint interface {
    20  	type int
    21  }
    22  
    23  func _[T constraint](x interface{}){
    24  	switch x.(type) {
    25  	case T: // ok to use a type parameter even if type list contains int
    26  	case int:
    27  	}
    28  }
    29  
    30  func _(x constraint /* ERROR contains type constraints */ ) {
    31  	switch x /* ERROR contains type constraints */ .(type) {
    32  	}
    33  }
    34  

View as plain text