File tree 5 files changed +33
-39
lines changed
5 files changed +33
-39
lines changed Original file line number Diff line number Diff line change @@ -399,9 +399,9 @@ func (r *reader) readFunc(fun *ast.FuncDecl) {
399
399
// with the first type in result signature (there may
400
400
// be more than one result)
401
401
factoryType := res .Type
402
- if t , ok := factoryType .(* ast.ArrayType ); ok && t . Len == nil {
403
- // We consider functions that return slices of type T (or
404
- // pointers to T) as factory functions of T.
402
+ if t , ok := factoryType .(* ast.ArrayType ); ok {
403
+ // We consider functions that return slices or arrays of type
404
+ // T (or pointers to T) as factory functions of T.
405
405
factoryType = t .Elt
406
406
}
407
407
if n , imp := baseTypeName (factoryType ); ! imp && r .isVisible (n ) {
Original file line number Diff line number Diff line change 1
1
//
2
- PACKAGE issue18063
2
+ PACKAGE issue22856
3
3
4
4
IMPORTPATH
5
- testdata/issue18063
5
+ testdata/issue22856
6
6
7
7
FILENAMES
8
- testdata/issue18063 .go
8
+ testdata/issue22856 .go
9
9
10
10
FUNCTIONS
11
- // NewArray is not a factory function because arrays of type T are ...
12
- func NewArray() [1]T
13
-
14
- // NewPointerArray is not a factory function because arrays of ...
15
- func NewPointerArray() [1]*T
16
-
17
11
// NewPointerSliceOfSlice is not a factory function because slices ...
18
12
func NewPointerSliceOfSlice() [][]*T
19
13
31
25
//
32
26
func New() T
33
27
28
+ //
29
+ func NewArray() [1]T
30
+
34
31
//
35
32
func NewPointer() *T
36
33
34
+ //
35
+ func NewPointerArray() [1]*T
36
+
37
37
//
38
38
func NewPointerOfPointer() **T
39
39
Original file line number Diff line number Diff line change 1
1
//
2
- PACKAGE issue18063
2
+ PACKAGE issue22856
3
3
4
4
IMPORTPATH
5
- testdata/issue18063
5
+ testdata/issue22856
6
6
7
7
FILENAMES
8
- testdata/issue18063 .go
8
+ testdata/issue22856 .go
9
9
10
10
FUNCTIONS
11
- // NewArray is not a factory function because arrays of type T are ...
12
- func NewArray() [1]T
13
-
14
- // NewPointerArray is not a factory function because arrays of ...
15
- func NewPointerArray() [1]*T
16
-
17
11
// NewPointerSliceOfSlice is not a factory function because slices ...
18
12
func NewPointerSliceOfSlice() [][]*T
19
13
31
25
//
32
26
func New() T
33
27
28
+ //
29
+ func NewArray() [1]T
30
+
34
31
//
35
32
func NewPointer() *T
36
33
34
+ //
35
+ func NewPointerArray() [1]*T
36
+
37
37
//
38
38
func NewPointerOfPointer() **T
39
39
Original file line number Diff line number Diff line change 1
1
//
2
- PACKAGE issue18063
2
+ PACKAGE issue22856
3
3
4
4
IMPORTPATH
5
- testdata/issue18063
5
+ testdata/issue22856
6
6
7
7
FILENAMES
8
- testdata/issue18063 .go
8
+ testdata/issue22856 .go
9
9
10
10
FUNCTIONS
11
- // NewArray is not a factory function because arrays of type T are ...
12
- func NewArray() [1]T
13
-
14
- // NewPointerArray is not a factory function because arrays of ...
15
- func NewPointerArray() [1]*T
16
-
17
11
// NewPointerSliceOfSlice is not a factory function because slices ...
18
12
func NewPointerSliceOfSlice() [][]*T
19
13
31
25
//
32
26
func New() T
33
27
28
+ //
29
+ func NewArray() [1]T
30
+
34
31
//
35
32
func NewPointer() *T
36
33
34
+ //
35
+ func NewPointerArray() [1]*T
36
+
37
37
//
38
38
func NewPointerOfPointer() **T
39
39
Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- package issue18063
5
+ package issue22856
6
6
7
7
type T struct {}
8
8
@@ -11,14 +11,8 @@ func NewPointer() *T { return &T{} }
11
11
func NewPointerSlice () []* T { return []* T {& T {}} }
12
12
func NewSlice () []T { return []T {T {}} }
13
13
func NewPointerOfPointer () * * T { x := & T {}; return & x }
14
-
15
- // NewArray is not a factory function because arrays of type T are not
16
- // factory functions of type T.
17
- func NewArray () [1 ]T { return [1 ]T {T {}} }
18
-
19
- // NewPointerArray is not a factory function because arrays of type *T are not
20
- // factory functions of type T.
21
- func NewPointerArray () [1 ]* T { return [1 ]* T {& T {}} }
14
+ func NewArray () [1 ]T { return [1 ]T {T {}} }
15
+ func NewPointerArray () [1 ]* T { return [1 ]* T {& T {}} }
22
16
23
17
// NewSliceOfSlice is not a factory function because slices of a slice of
24
18
// type *T are not factory functions of type T.
You can’t perform that action at this time.
0 commit comments