Source file test/fixedbugs/issue81354.go

     1  // compile
     2  
     3  // Copyright 2026 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  import "reflect"
    10  
    11  type E struct{}
    12  
    13  func (E) M() {}
    14  
    15  func g(x struct{ a, b int }) {
    16  	reflect.ValueOf(x)
    17  }
    18  
    19  func gEmbedded(x struct {
    20  	E
    21  	b int
    22  }) {
    23  	reflect.ValueOf(x)
    24  }
    25  
    26  func f[T any](i interface{}) {
    27  	switch i.(type) {
    28  	case T:
    29  	case struct{ a, b T }:
    30  	}
    31  }
    32  
    33  func fEmbedded[T any](i interface{}) {
    34  	switch i.(type) {
    35  	case T:
    36  	case struct {
    37  		E
    38  		b T
    39  	}:
    40  	}
    41  }
    42  
    43  func main() {
    44  	f[int](0)
    45  	f[any](0)
    46  	fEmbedded[int](0)
    47  	fEmbedded[any](0)
    48  }
    49  

View as plain text