go/types: minor adjustment to an error message and comments

Change-Id: Ie9505d508507c9ed764ec725df1027c92bae0702
This commit is contained in:
Robert Griesemer 2020-02-03 16:05:10 -08:00
parent e70e49973e
commit 3ab56f5ff2
2 changed files with 8 additions and 6 deletions

View File

@ -73,9 +73,11 @@ func (check *Checker) infer(pos token.Pos, tparams []*TypeName, params *Tuple, a
// infer an untyped nil type as type parameter type. Ignore untyped
// nil by making sure all default argument types are typed.
if isTyped(targ) && !check.identical0(par.typ, targ, true, nil, targs) {
check.errorf(arg.pos(), "default type %s for %s does not match %s = %s",
Default(arg.typ), arg.expr, par.typ, check.subst(pos, par.typ, tparams, targs),
)
// TODO(gri) see TODO comment above
// check.errorf(arg.pos(), "default type %s for %s does not match %s = %s",
// Default(arg.typ), arg.expr, par.typ, check.subst(pos, par.typ, tparams, targs),
// )
check.errorf(arg.pos(), "default type %s for %s does not match %s", Default(arg.typ), arg.expr, par.typ)
return nil
}
}

View File

@ -362,14 +362,14 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
// does not instantiate the methods).
// In order to compare the signatures, substitute the receiver
// type parameters of ftyp with V's instantiation type arguments.
// This lazily instantiates the method f.
if Vn != nil {
// This lazily instantiates the signature of method f.
if Vn != nil && len(Vn.targs) > 0 {
ftyp = check.subst(token.NoPos, ftyp, ftyp.rparams, Vn.targs).(*Signature)
}
// If the methods have type parameters we don't care whether they
// are the same or not, as long as they match up. Use inference
// comparison in that case.
// comparison (provide non-nil tparams to identical0) in that case.
// TODO(gri) is this always correct? what about type bounds?
// (Alternative is to rename/subst type parameters and compare.)
var tparams []Type