Source file src/internal/types/testdata/fixedbugs/issue60946.go

     1  // Copyright 2023 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  type Tn interface{ m() }
     8  type T1 struct{}
     9  type T2 struct{}
    10  
    11  func (*T1) m() {}
    12  func (*T2) m() {}
    13  
    14  func g[P any](...P) {}
    15  
    16  func _() {
    17  	var t interface{ m() }
    18  	var tn Tn
    19  	var t1 *T1
    20  	var t2 *T2
    21  
    22  	// these are ok (interface types only)
    23  	g(t, t)
    24  	g(t, tn)
    25  	g(tn, t)
    26  	g(tn, tn)
    27  
    28  	// these are not ok (interface and non-interface types)
    29  	g(t, t1 /* ERROR "does not match" */)
    30  	g(t1, t /* ERROR "does not match" */)
    31  	g(tn, t1 /* ERROR "does not match" */)
    32  	g(t1, tn /* ERROR "does not match" */)
    33  
    34  	g(t, t1 /* ERROR "does not match" */, t2)
    35  	g(t1, t2 /* ERROR "does not match" */, t)
    36  	g(tn, t1 /* ERROR "does not match" */, t2)
    37  	g(t1, t2 /* ERROR "does not match" */, tn)
    38  }
    39  

View as plain text