@@ -63,10 +63,6 @@ func (u *unifier) unify(x, y Type) bool {
63
63
type tparamsList struct {
64
64
unifier * unifier
65
65
tparams []* TypeParam
66
- // For each tparams element, there is a corresponding mask bit in masks.
67
- // If set, the corresponding type parameter is masked and doesn't appear
68
- // as a type parameter with tparamsList.index.
69
- masks []bool
70
66
// For each tparams element, there is a corresponding type slot index in indices.
71
67
// index < 0: unifier.types[-index-1] == nil
72
68
// index == 0: no type slot allocated yet
@@ -107,14 +103,9 @@ func (d *tparamsList) init(tparams []*TypeParam) {
107
103
}
108
104
}
109
105
d .tparams = tparams
110
- d .masks = make ([]bool , len (tparams ))
111
106
d .indices = make ([]int , len (tparams ))
112
107
}
113
108
114
- // mask and unmask permit the masking/unmasking of the i'th type parameter of d.
115
- func (d * tparamsList ) mask (i int ) { d .masks [i ] = true }
116
- func (d * tparamsList ) unmask (i int ) { d .masks [i ] = false }
117
-
118
109
// join unifies the i'th type parameter of x with the j'th type parameter of y.
119
110
// If both type parameters already have a type associated with them and they are
120
111
// not joined, join fails and returns false.
@@ -158,13 +149,11 @@ func (u *unifier) join(i, j int) bool {
158
149
return true
159
150
}
160
151
161
- // If typ is an unmasked type parameter of d, index returns the type parameter index.
152
+ // If typ is a type parameter of d, index returns the type parameter index.
162
153
// Otherwise, the result is < 0.
163
154
func (d * tparamsList ) index (typ Type ) int {
164
155
if tpar , ok := typ .(* TypeParam ); ok {
165
- if i := tparamIndex (d .tparams , tpar ); i >= 0 && ! d .masks [i ] {
166
- return i
167
- }
156
+ return tparamIndex (d .tparams , tpar )
168
157
}
169
158
return - 1
170
159
}
@@ -257,7 +246,7 @@ func (u *unifier) nify(x, y Type, p *ifacePair) bool {
257
246
}
258
247
}
259
248
260
- // Cases where at least one of x or y is an (unmasked) type parameter.
249
+ // Cases where at least one of x or y is a type parameter.
261
250
switch i , j := u .x .index (x ), u .y .index (y ); {
262
251
case i >= 0 && j >= 0 :
263
252
// both x and y are type parameters
@@ -270,12 +259,6 @@ func (u *unifier) nify(x, y Type, p *ifacePair) bool {
270
259
case i >= 0 :
271
260
// x is a type parameter, y is not
272
261
if tx := u .x .at (i ); tx != nil {
273
- // The inferred type tx may be or contain x again but we don't
274
- // want to "unpack" it again when unifying tx with y: tx is the
275
- // inferred type. Mask type parameter x for this recursion, so
276
- // that subsequent encounters treat x like an ordinary type.
277
- u .x .mask (i )
278
- defer u .x .unmask (i )
279
262
return u .nifyEq (tx , y , p )
280
263
}
281
264
// otherwise, infer type from y
@@ -285,9 +268,6 @@ func (u *unifier) nify(x, y Type, p *ifacePair) bool {
285
268
case j >= 0 :
286
269
// y is a type parameter, x is not
287
270
if ty := u .y .at (j ); ty != nil {
288
- // see comment above
289
- u .y .mask (j )
290
- defer u .y .unmask (j )
291
271
return u .nifyEq (x , ty , p )
292
272
}
293
273
// otherwise, infer type from x
0 commit comments