Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
issue51522b.go63 linesDownload Raw Back to typeparam
1// run2 3// Copyright 2022 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7package main8 9func f[T comparable](i any) {10	var t T11 12	switch i {13	case t:14		// ok15	default:16		println("FAIL: switch i")17	}18 19	switch t {20	case i:21		// ok22	default:23		println("FAIL: switch t")24	}25}26 27type myint int28 29func (m myint) foo() {30}31 32type fooer interface {33	foo()34}35 36type comparableFoo interface {37	comparable38	foo()39}40 41func g[T comparableFoo](i fooer) {42	var t T43 44	switch i {45	case t:46		// ok47	default:48		println("FAIL: switch i")49	}50 51	switch t {52	case i:53		// ok54	default:55		println("FAIL: switch t")56	}57}58 59func main() {60	f[int](0)61	g[myint](myint(0))62}63 
codekingpro/portable-devtools · Team Ai