File tree 2 files changed +12
-13
lines changed 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -259,28 +259,23 @@ func (subst *subster) typ(typ Type) Type {
259
259
var instanceHashing = 0
260
260
261
261
func instantiatedHash (typ * Named , targs []Type ) string {
262
+ var buf bytes.Buffer
263
+
262
264
assert (instanceHashing == 0 )
263
265
instanceHashing ++
264
- var buf bytes.Buffer
265
266
w := newTypeWriter (& buf , nil )
266
267
w .typeName (typ .obj )
267
268
w .typeList (targs )
268
269
instanceHashing --
269
270
270
- // With respect to the represented type, whether a
271
- // type is fully expanded or stored as instance
272
- // does not matter - they are the same types.
273
- // Remove the instanceMarkers printed for instances.
274
- res := buf .Bytes ()
275
- i := 0
276
- for _ , b := range res {
277
- if b != instanceMarker {
278
- res [i ] = b
279
- i ++
271
+ if debug {
272
+ // there should be no instance markers in type hashes
273
+ for _ , b := range buf .Bytes () {
274
+ assert (b != instanceMarker )
280
275
}
281
276
}
282
277
283
- return string ( res [: i ] )
278
+ return buf . String ( )
284
279
}
285
280
286
281
// typOrNil is like typ but if the argument is nil it is replaced with Typ[Invalid].
Original file line number Diff line number Diff line change @@ -204,7 +204,11 @@ func (w *typeWriter) typ(typ Type) {
204
204
}
205
205
206
206
case * Named :
207
- if t .instPos != nil {
207
+ // Instance markers indicate unexpanded instantiated
208
+ // types. Write them to aid debugging, but don't write
209
+ // them when we need an instance hash: whether a type
210
+ // is fully expanded or not doesn't matter for identity.
211
+ if instanceHashing == 0 && t .instPos != nil {
208
212
w .byte (instanceMarker )
209
213
}
210
214
w .typeName (t .obj )
You can’t perform that action at this time.
0 commit comments