1 // Copyright 2021 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 resolution
6
7 type List /* =@List */ [E /* =@E */ any] []E // @E
8
9 type Pair /* =@Pair */ [L /* =@L */, R /* =@R */ any] struct {
10 Left /* =@Left */ L // @L
11 Right /* =@Right */ R // @R
12 L /* =@Lfield */ int
13 }
14
15 var _ = Pair /* @Pair */ [int, string]{}
16
17 type Addable /* =@Addable */ interface {
18 type int64, float64
19 }
20
21 func Add /* =@AddDecl */[T /* =@T */ Addable /* @Addable */](l /* =@l */, r /* =@r */ T /* @T */) T /* @T */ {
22 var t /* =@t */ T /* @T */
23 return l /* @l */ + r /* @r */ + t /* @t */
24 }
25
26 type Receiver /* =@Receiver */[P /* =@P */ any] struct {}
27
28 // TODO(rFindley): make a decision on how/whether to resolve identifiers that
29 // refer to receiver type parameters, as is the case for the 'P' result
30 // parameter below.
31 func (r /* =@recv */ Receiver /* @Receiver */ [P]) m() P {}
32
33 func f /* =@f */[T1 /* =@T1 */ interface{type []T2 /* @T2 */}, T2 /* =@T2 */ any](
34 x /* =@x */ T1 /* @T1 */, T1 /* =@T1_duplicate */ y, // Note that this is a bug:
35 // the duplicate T1 should
36 // not be allowed.
37 ){
38 // Note that duplicate short var declarations resolve to their alt declaration.
39 x /* @x */ := 0
40 y /* =@y */ := 0
41 T1 /* @T1 */ := 0
42 var t1var /* =@t1var */ T1 /* @T1 */
43 }
44
View as plain text