Source file test/typeparam/mdempsky/21.go

     1  // run
     2  
     3  // Copyright 2022 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  // Test that devirtualization doesn't introduce spurious type
     8  // assertion failures due to shaped and non-shaped interfaces having
     9  // distinct itabs.
    10  
    11  package main
    12  
    13  func main() {
    14  	F[int]()
    15  }
    16  
    17  func F[T any]() {
    18  	var i I[T] = X(0)
    19  	i.M()
    20  }
    21  
    22  type I[T any] interface{ M() }
    23  
    24  type X int
    25  
    26  func (X) M() {}
    27  

View as plain text