@@ -30,7 +30,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
30
30
}
31
31
32
32
if traceInference {
33
- check .dump ("-- infer %s%s ➞ %s" , tparams , params , targs )
33
+ check .dump ("== infer : %s%s ➞ %s" , tparams , params , targs ) // aligned with rename print below
34
34
defer func () {
35
35
check .dump ("=> %s ➞ %s\n " , tparams , inferred )
36
36
}()
@@ -53,7 +53,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
53
53
tparams , params = check .renameTParams (pos , tparams , params )
54
54
55
55
if traceInference {
56
- check .dump ("after rename: %s%s ➞ %s\n " , tparams , params , targs )
56
+ check .dump ("-- rename: %s%s ➞ %s\n " , tparams , params , targs )
57
57
}
58
58
59
59
// Make sure we have a "full" list of type arguments, some of which may
@@ -142,8 +142,8 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
142
142
// use information from function arguments
143
143
144
144
if traceInference {
145
- u .tracef ("parameters: %s" , params )
146
- u .tracef ("arguments : %s" , args )
145
+ u .tracef ("== function parameters: %s" , params )
146
+ u .tracef ("-- function arguments : %s" , args )
147
147
}
148
148
149
149
for i , arg := range args {
@@ -183,7 +183,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
183
183
// use information from type parameter constraints
184
184
185
185
if traceInference {
186
- u .tracef ("type parameters: %s" , tparams )
186
+ u .tracef ("== type parameters: %s" , tparams )
187
187
}
188
188
189
189
// Unify type parameters with their constraints as long
@@ -201,21 +201,25 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
201
201
// here could handle the respective type parameters only,
202
202
// but that will come at a cost of extra complexity which
203
203
// may not be worth it.)
204
- for {
204
+ for i := 0 ; ; i ++ {
205
205
nn := u .unknowns ()
206
+ if traceInference {
207
+ if i > 0 {
208
+ fmt .Println ()
209
+ }
210
+ u .tracef ("-- iteration %d" , i )
211
+ }
206
212
207
213
for _ , tpar := range tparams {
208
214
tx := u .at (tpar )
209
- if traceInference && tx != nil {
210
- u .tracef ("%s = %s" , tpar , tx )
215
+ core , single := coreTerm (tpar )
216
+ if traceInference {
217
+ u .tracef ("-- type parameter %s = %s: core(%s) = %s, single = %v" , tpar , tx , tpar , core , single )
211
218
}
212
219
213
220
// If there is a core term (i.e., a core type with tilde information)
214
221
// unify the type parameter with the core type.
215
- if core , single := coreTerm (tpar ); core != nil {
216
- if traceInference {
217
- u .tracef ("core(%s) = %s (single = %v)" , tpar , core , single )
218
- }
222
+ if core != nil {
219
223
// A type parameter can be unified with its core type in two cases.
220
224
switch {
221
225
case tx != nil :
@@ -240,9 +244,6 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
240
244
u .set (tpar , core .typ )
241
245
}
242
246
} else {
243
- if traceInference {
244
- u .tracef ("core(%s) = nil" , tpar )
245
- }
246
247
if tx != nil {
247
248
// We don't have a core type, but the type argument tx is known.
248
249
// It must have (at least) all the methods of the type constraint,
@@ -272,7 +273,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
272
273
// use information from untyped contants
273
274
274
275
if traceInference {
275
- u .tracef ("untyped: %v" , untyped )
276
+ u .tracef ("== untyped arguments : %v" , untyped )
276
277
}
277
278
278
279
// Some generic parameters with untyped arguments may have been given a type by now.
0 commit comments