File tree 2 files changed +41
-1
lines changed
cmd/compile/internal/staticdata
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ func embedKind(typ *types.Type) int {
73
73
if typ .Kind () == types .TSTRING {
74
74
return embedString
75
75
}
76
- if typ .Sym () == nil && typ . IsSlice () && typ .Elem ().Kind () == types .TUINT8 {
76
+ if typ .IsSlice () && typ .Elem ().Kind () == types .TUINT8 {
77
77
return embedBytes
78
78
}
79
79
return embedUnknown
Original file line number Diff line number Diff line change @@ -129,3 +129,43 @@ func TestUninitialized(t *testing.T) {
129
129
t .Errorf ("in uninitialized embed.FS, . is not a directory" )
130
130
}
131
131
}
132
+
133
+ var (
134
+ //go:embed "testdata/hello.txt"
135
+ helloT []T
136
+ //go:embed "testdata/hello.txt"
137
+ helloUint8 []uint8
138
+ //go:embed "testdata/hello.txt"
139
+ helloEUint8 []EmbedUint8
140
+ //go:embed "testdata/hello.txt"
141
+ helloBytes EmbedBytes
142
+ //go:embed "testdata/hello.txt"
143
+ helloString EmbedString
144
+ )
145
+
146
+ type T byte
147
+ type EmbedUint8 uint8
148
+ type EmbedBytes []byte
149
+ type EmbedString string
150
+
151
+ // golang.org/issue/47735
152
+ func TestAliases (t * testing.T ) {
153
+ all := testDirAll
154
+ want , e := all .ReadFile ("testdata/hello.txt" )
155
+ if e != nil {
156
+ t .Fatal ("ReadFile:" , e )
157
+ }
158
+ check := func (g interface {}) {
159
+ got := reflect .ValueOf (g )
160
+ for i := 0 ; i < got .Len (); i ++ {
161
+ if byte (got .Index (i ).Uint ()) != want [i ] {
162
+ t .Fatalf ("got %v want %v" , got .Bytes (), want )
163
+ }
164
+ }
165
+ }
166
+ check (helloT )
167
+ check (helloUint8 )
168
+ check (helloEUint8 )
169
+ check (helloBytes )
170
+ check (helloString )
171
+ }
You can’t perform that action at this time.
0 commit comments