summaryrefslogtreecommitdiff
path: root/src/pkg/go/types/testdata/decls2a.src
blob: 3867be737653d80c4f59ed9de8e6a9552e05cc88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// method declarations

package decls2

import "time"

// T1 declared before its methods.
type T1 struct{
	f int
}

func (T1) m() {}
func (T1) m /* ERROR "redeclared" */ () {}
func (x *T1) f /* ERROR "field and method" */ () {}

// T2's method declared before the type.
func (*T2) f /* ERROR "field and method" */ () {}

type T2 struct {
	f int
}

// Methods declared without a declared type.
func (undeclared /* ERROR "undeclared" */) m() {}
func (x *undeclared /* ERROR "undeclared" */) m() {}

// TODO(gri) try to get rid of double error reporting here
func (pi /* ERROR "not a type" */) m1() {}
func (x pi /* ERROR "not a type" */) m2() {}
func (x *pi /* ERROR "not a type" */ ) m3() {} // TODO(gri) not closing the last /* comment crashes the system

// Blank types.
type _ struct { m int }
type _ struct { m int }

// TODO(gri) blank idents not fully checked - disabled for now
// func (_ /* ERROR "cannot use _" */) m() {}
// func (_ /* ERROR "cannot use _" */) m() {}

// Methods with receiver base type declared in another file.
func (T3) m1() {}
func (*T3) m2() {}
func (x T3) m3() {}
func (x *T3) f /* ERROR "field and method" */ () {}

// Methods of non-struct type.
type T4 func()

func (self T4) m() func() { return self }

// Methods associated with an interface.
type T5 interface {
	m() int
}

func (T5 /* ERROR "invalid receiver" */) m1() {}
func (T5 /* ERROR "invalid receiver" */) m2() {}

// Methods associated with non-local or unnamed types.
func (int /* ERROR "non-local type" */ ) m() {}
func ([ /* ERROR "expected" */ ]int) m() {}
func (time /* ERROR "expected" */ .Time) m() {}
func (x interface /* ERROR "expected" */ {}) m() {}