// 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() {}
