Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
issue47708.go38 linesDownload Raw Back to typeparam
1// run2 3// Copyright 2021 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 9type FooType[T any] interface {10	Foo(BarType[T]) string11}12type BarType[T any] interface {13	Bar(FooType[T]) string14}15 16// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639).17// type Baz[T any] T18// func (l Baz[T]) Foo(v BarType[T]) string {19// 	return v.Bar(l)20// }21// type Bob[T any] T22// func (l Bob[T]) Bar(v FooType[T]) string {23// 	if v,ok := v.(Baz[T]);ok{24// 		return fmt.Sprintf("%v%v",v,l)25// 	}26// 	return ""27// }28 29func main() {30	// For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639).31	// var baz Baz[int] = 12332	// var bob Bob[int] = 45633	//34	// if got, want := baz.Foo(bob), "123456"; got != want {35	// 	panic(fmt.Sprintf("got %s want %s", got, want))36	// }37}38 
codekingpro/portable-devtools · Team Ai