Source file test/fixedbugs/issue47904.dir/main.go
1 // Copyright 2026 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 main 6 7 import ( 8 "reflect" 9 10 "./a" 11 "./b" 12 ) 13 14 // Comparing two interfaces whose dynamic type the compiler knows is 15 // compiled to a direct comparison, so compare through a function that has 16 // to go through the type descriptor at run time. 17 // 18 //go:noinline 19 func eq(x, y any) bool { return x == y } 20 21 func main() { 22 // main never mentions [2]a.K itself, so the only descriptors for it 23 // are the ones in packages a and b. 24 _ = a.Sink 25 x, y := b.Get(), b.Get() 26 if !reflect.TypeOf(x).Comparable() { 27 panic("descriptor for [2]a.K has no equality function") 28 } 29 if !eq(x, y) { 30 panic("[2]a.K values compare unequal") 31 } 32 } 33