1// Copyright 2017 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 5package issue18063 6 7type T struct{} 8 9func New() T { return T{} } 10func NewPointer() *T { return &T{} } 11func NewPointerSlice() []*T { return []*T{&T{}} } 12func NewSlice() []T { return []T{T{}} } 13func 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. 17func 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. 21func NewPointerArray() [1]*T { return [1]*T{&T{}} } 22 23// NewSliceOfSlice is not a factory function because slices of a slice of 24// type *T are not factory functions of type T. 25func NewSliceOfSlice() [][]T { return []T{[]T{}} } 26 27// NewPointerSliceOfSlice is not a factory function because slices of a 28// slice of type *T are not factory functions of type T. 29func NewPointerSliceOfSlice() [][]*T { return []*T{[]*T{}} } 30 31// NewSlice3 is not a factory function because 3 nested slices of type T 32// are not factory functions of type T. 33func NewSlice3() [][][]T { return []T{[]T{[]T{}}} } 34