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
68
69
|
// Copyright 2018 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.
// Package issue12839 is a go/doc test to test association of a function
// that returns multiple types.
// See golang.org/issue/12839.
// (See also golang.org/issue/27928.)
package issue12839
import "p"
type T1 struct{}
type T2 struct{}
func (t T1) hello() string {
return "hello"
}
// F1 should not be associated with T1
func F1() (*T1, *T2) {
return &T1{}, &T2{}
}
// F2 should be associated with T1
func F2() (a, b, c T1) {
return T1{}, T1{}, T1{}
}
// F3 should be associated with T1 because b.T3 is from a different package
func F3() (a T1, b p.T3) {
return T1{}, p.T3{}
}
// F4 should not be associated with a type (same as F1)
func F4() (a T1, b T2) {
return T1{}, T2{}
}
// F5 should be associated with T1.
func F5() (T1, error) {
return T1{}, nil
}
// F6 should be associated with T1.
func F6() (*T1, error) {
return &T1{}, nil
}
// F7 should be associated with T1.
func F7() (T1, string) {
return T1{}, nil
}
// F8 should be associated with T1.
func F8() (int, T1, string) {
return 0, T1{}, nil
}
// F9 should not be associated with T1.
func F9() (int, T1, T2) {
return 0, T1{}, T2{}
}
// F10 should not be associated with T1.
func F10() (T1, T2, error) {
return T1{}, T2{}, nil
}
|