Source file test/typeparam/devirtualize2.go
1 // run 2 3 // Copyright 2023 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 S struct { 10 x int 11 } 12 13 func (t *S) M1() { 14 } 15 func (t *S) M2() { 16 } 17 18 type I interface { 19 M1() 20 } 21 22 func F[T I](x T) I { 23 return x 24 } 25 26 func main() { 27 F(&S{}).(interface{ M2() }).M2() 28 } 29