Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
issue50417.go147 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 main() {}10 11// Field accesses through type parameters are disabled12// until we have a more thorough understanding of the13// implications on the spec. See issue #51576.14 15/*16type Sf struct {17	f int18}19 20func f0[P Sf](p P) {21	_ = p.f22	p.f = 023}24 25func f0t[P ~struct{ f int }](p P) {26	_ = p.f27	p.f = 028}29 30var _ = f0[Sf]31var _ = f0t[Sf]32 33func f1[P interface {34	~struct{ f int }35	m()36}](p P) {37	_ = p.f38	p.f = 039	p.m()40}41 42var _ = f1[Sfm]43 44type Sm struct{}45 46func (Sm) m() {}47 48type Sfm struct {49	f int50}51 52func (Sfm) m() {}53 54func f2[P interface {55	Sfm56	m()57}](p P) {58	_ = p.f59	p.f = 060	p.m()61}62 63var _ = f2[Sfm]64 65// special case: core type is a named pointer type66 67type PSfm *Sfm68 69func f3[P interface{ PSfm }](p P) {70	_ = p.f71	p.f = 072}73 74var _ = f3[PSfm]75 76// special case: core type is an unnamed pointer type77 78func f4[P interface{ *Sfm }](p P) {79	_ = p.f80	p.f = 081}82 83var _ = f4[*Sfm]84 85type A int86type B int87type C float6488 89type Int interface {90	*Sf | A91	*Sf | B92}93 94func f5[P Int](p P) {95	_ = p.f96	p.f = 097}98 99var _ = f5[*Sf]100 101type Int2 interface {102	*Sf | A103	any104	*Sf | C105}106 107func f6[P Int2](p P) {108	_ = p.f109	p.f = 0110}111 112var _ = f6[*Sf]113 114type Int3 interface {115	Sf116	~struct{ f int }117}118 119func f7[P Int3](p P) {120	_ = p.f121	p.f = 0122}123 124var _ = f7[Sf]125 126type Em1 interface {127	*Sf | A128}129 130type Em2 interface {131	*Sf | B132}133 134type Int4 interface {135	Em1136	Em2137	any138}139 140func f8[P Int4](p P) {141	_ = p.f142	p.f = 0143}144 145var _ = f8[*Sf]146*/147 
codekingpro/portable-devtools · Team Ai