| 1 |
-- go.mod -- |
| 2 |
module example.com |
| 3 |
|
| 4 |
go 1.24 |
| 5 |
|
| 6 |
-- baz/baz.go -- |
| 7 |
package baz |
| 8 |
|
| 9 |
type Baz int |
| 10 |
|
| 11 |
type Baz2 int |
| 12 |
|
| 13 |
type GenericBaz[T any] struct{} |
| 14 |
|
| 15 |
-- test.go -- |
| 16 |
package t |
| 17 |
|
| 18 |
import "example.com/baz" |
| 19 |
|
| 20 |
type Foo int |
| 21 |
|
| 22 |
//go:fix inline |
| 23 |
type Bar = Foo // want Bar:"goFixInline alias" |
| 24 |
|
| 25 |
type _ struct { |
| 26 |
// Bar should not be inlined, since that would cause |
| 27 |
// a field name change. |
| 28 |
Bar |
| 29 |
} |
| 30 |
|
| 31 |
type _ struct { |
| 32 |
// *Bar should not be inlined, since that would cause |
| 33 |
// a field name change. |
| 34 |
*Bar |
| 35 |
} |
| 36 |
|
| 37 |
//go:fix inline |
| 38 |
type Baz = baz.Baz // want Baz:"goFixInline alias" |
| 39 |
|
| 40 |
type _ struct { |
| 41 |
// fine, since will end up with the same name. |
| 42 |
Baz // want `Type alias Baz should be inlined` |
| 43 |
} |
| 44 |
|
| 45 |
type _ struct { |
| 46 |
// fine, since will end up with the same name. |
| 47 |
*Baz // want `Type alias Baz should be inlined` |
| 48 |
} |
| 49 |
|
| 50 |
//go:fix inline |
| 51 |
type StructAlias = struct {} // want StructAlias:"goFixInline alias" |
| 52 |
|
| 53 |
type _ struct { |
| 54 |
// type _ struct { struct{} } would not be a valid Go. |
| 55 |
StructAlias |
| 56 |
} |
| 57 |
|
| 58 |
//go:fix inline |
| 59 |
type GenericFoo[T any] = Foo // want GenericFoo:"goFixInline alias" |
| 60 |
|
| 61 |
type _ struct { |
| 62 |
GenericFoo[int] |
| 63 |
} |
| 64 |
|
| 65 |
type _ struct { |
| 66 |
GenericFoo[Baz] // want `Type alias Baz should be inlined` |
| 67 |
} |
| 68 |
|
| 69 |
//go:fix inline |
| 70 |
type Baz2[T any] = baz.Baz2 // want Baz2:"goFixInline alias" |
| 71 |
|
| 72 |
type _ struct { |
| 73 |
Baz2[int] // want `Type alias Baz2\[int\] should be inlined` |
| 74 |
} |
| 75 |
|
| 76 |
//go:fix inline |
| 77 |
type GenericBaz[T any] = baz.GenericBaz[T] // want GenericBaz:"goFixInline alias" |
| 78 |
|
| 79 |
type _ struct { |
| 80 |
GenericBaz[int] // want `Type alias GenericBaz\[int\] should be inlined` |
| 81 |
} |